ERICK'S BLOG
  • Home
  • Anime
  • Music
  • Blog
  • Apps
    • Mortgage Calculator
  • Windchill
    • Windchill Customizations
    • E.P.L.E.S.
    • Export Released
    • Document Exporter
    • Document Worker
    • Property Checker
    • Windchill Business Analytics >
      • Part 01 - Program Logic
      • Part 02 - Getting Data with SQL Queries
      • Part 03 - Automating SQL Queries
      • Part 04 - Converting SQL Results to XML
      • Part 05 - Data Processing and Manipulation
      • Part 06 - Displaying XML in HTML
      • Part 07 - Auto Updating Displayed Data
      • Part 08 - Hosting Webpage with an Existing Apache Installation
      • Part 09 - Running Multiple Queries In Sequence
      • Part 10 - Calculating Data Trends
      • Part 11 - Making It Modular
    • Windchill Quick View
  • PowerShell
    • Blog & Examples
    • Excel Reference
  • Contact

How to Customize Windchill 13 - Part 2: Creating Your First Listener

5/17/2024

0 Comments

 
Picture
I'm not going to start you off with some waste-of-time "Hello World!" app.  We are going to go straight into making useful code. 

Creating a listener gives you the ability to automate actions.  Let's say you wanted to kickoff another piece of code whenever a user created a new revision.  You could either write something that queries for new revisions every so often (boring) or make a listener to runs that code on the fly.  Let's create our first listener!
Reference link: 
  • www.ptc.com/en/support/article/CS213788
​Java Docs:
  • https://www.ptc.com/en/support/refdoc/Windchill_PDMLink/13.0/WindchillJavadoc_13_0_1_0
Note:  This goes for all code on this site.  I am just giving you the quickest path from point A to B.  It is up to you to fully build out the rest of the code i.e. error handling, unit testing, logging, etc.  Don't let that scare you away.  You aren't building some major app here.  I am just trying to make you aware that what I give you might work in some instances but not others.  You must problem solve to figure out how to tweak it to make it reliable and safe.

Code the Listener in Java

  1. Open Eclipse.
    1. Go to Project Explorer and right click on cust_Windchill_src.
    2. Select New -> Class.
  2. You should see a New Java Class window popup.
    1. For the Package name, it is typical to start with ext followed by your domain name that you used for Windchill backwards which is then followed by something to categorize what you are doing.  If you are buying a customization, you will usually see it reference the other company's name.
      1. I will set mine to be ext.com.mycompany.listeners.
    2. For the Name box, this is the actual Class name, we want to give it something relevant and unique.
      1. You can get away with WTDocumentListenerAdapter.
    3. Leave everything else as is and click Finish.
  3. You will now see the new WTDocumentListenerAdapter.java file opened in your view.
  4. Paste in the below code making sure to replace everything and modify the package name if different from yours.
    1. ​​I have put some comments in to try to explain what each line does.
    2. Click Save.
  5. ​Repeat steps 2-4 after right clicking on the newly created ext.com.mycompany.listeners -> New Class and create the WTDocumentListenerServer class.
  6. Repeat step 5 for the StandardWTDocumentListenerService class.
WTDocumentListenerAdapter.java

    
WTDocumentListenerService.java

    
StandardWTDocumentListenerService.java

    

Register the Listener with Windchill

We need to register the new service with Windchill so that it will be useable.
​
  1. Create a file in E:\ptc\Windchill\Windchill called myservice.xconf and paste in the code below making sure you are modifying the package name to match yours.
  2. Create another file in E:\ptc\Windchill\Windchill called myservice-wt.properties.xconf and paste in the code below.
  3. Open the site.xconf file and paste in the below property making sure it matches your configuration.
    1. Save the file.
  4. Open a Windchill Shell and run xconfmanager -p.
    1. Restart Windchill.
​myservice.xconf

    
​myservice-wt.properties.xconf

    
site.xconf Additions

    

Testing the Listener

  1. Login to Windchill with the orgadmin account.
    1. Go to any product or library and create a new Document.
  2. Check the latest method server log in E:\ptc\Windchill\Windchill\logs.
    1. The only logs that matter are the ones ending in -log4j.log.
  3. Scroll to the bottom on the log.
    1. You should see a message stating a new document was created with the document number and revision.
  4. Now revise the document.
  5. Check the logs.
    1. You should see the other message we coded when it detects a revision change.

Next Steps

You now have an automated way of triggering custom code.  Try figuring out the other event types like check out, check in, lifecycle state change, rename, etc.  Try setting up listeners for CAD and WTParts.  This is where you find out if this is for you.

Once you have your super listener created, you are ready for Part 3.
0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    Author

    Erick Johnson

    Archives

    August 2025
    June 2025
    May 2025
    May 2024
    July 2017
    May 2017
    February 2017
    January 2017
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016

    Categories

    All
    ASP.NET
    Batch Script
    C#
    Career
    Computers
    Creo
    Creo API
    GameMaker
    GitHub
    Home Loan
    How To
    HTML5
    Java
    JavaScript
    MAME
    Mortgage
    .NET Core
    Office
    PC Games
    PowerShell
    Robot
    SQL
    Video Games
    Web App
    Windchill
    Windchill API

    RSS Feed

Copyright © 2026 Erick Johnson
  • Home
  • Anime
  • Music
  • Blog
  • Apps
    • Mortgage Calculator
  • Windchill
    • Windchill Customizations
    • E.P.L.E.S.
    • Export Released
    • Document Exporter
    • Document Worker
    • Property Checker
    • Windchill Business Analytics >
      • Part 01 - Program Logic
      • Part 02 - Getting Data with SQL Queries
      • Part 03 - Automating SQL Queries
      • Part 04 - Converting SQL Results to XML
      • Part 05 - Data Processing and Manipulation
      • Part 06 - Displaying XML in HTML
      • Part 07 - Auto Updating Displayed Data
      • Part 08 - Hosting Webpage with an Existing Apache Installation
      • Part 09 - Running Multiple Queries In Sequence
      • Part 10 - Calculating Data Trends
      • Part 11 - Making It Modular
    • Windchill Quick View
  • PowerShell
    • Blog & Examples
    • Excel Reference
  • Contact