Skip to main content
5-Regular Member
July 6, 2023
Question

How can I get Part Where Used (Latest view) from REST API ?

  • July 6, 2023
  • 2 replies
  • 6585 views

I am using Windchill 12.1.2 with the following API to fetch a two level where used for a part, however it is returning Version B (RELEASED) and C (INWORK) for the same part in the results. The results mimic what I see in the Windchill UI on the Where Used tab using the All Revisions view. I want my REST API to return the results as if the Latest view on the Where Used tab is selected. How do I do that in my REST API?

https://<wc_host>/Windchill/servlet/odata/ProdMgmt/Parts('OR:wt.part.WTPart:143038')?$select=Identity,State&$expand=UsedBy($count=true;$levels=2;$select=Identity,State)

 

2 replies

14-Alexandrite
July 7, 2023

I believe you're just missing the "$filter=state eq 'RELEASED'" which you should be able to enter between your $select and $expand.  I used the REST tool in the Documentation page of Windchill to build this example.  Instead of filtering by state I just filtered the UsedBy results by PN, for this example.

 

WINDCHILL/servlet/odata/v5/ProdMgmt/Parts('OR%3Awt.part.WTPart%3A4277973910')/UsedBy?%24select=Identity%2CState&%24filter=Number%20eq%20'MyFilteredUsedByPartNumber'&%24count=true&%24expand=UsedBy(%24count%3Dtrue%3B%24levels%3D2%3B%24select%3DIdentity%2CState)

 So instead of Number eq 'yournumber' you'd just use State eq 'yourState'

tomnelson5-Regular MemberAuthor
5-Regular Member
July 7, 2023

Thank you for the suggestion, but I do not want to filter for only RELEASED state. I need the latest version. I want my REST API to return the same results as what is in the screenshot below of a Latest view Where Used.

wu_latest_view..png

The REST API , I posted above is returning the results that match an All Revisions view Where Used, see screenshot below. I DO NOT want that, I desire the Latest view results above.

wu_all_revisions_view..png

14-Alexandrite
July 7, 2023

Apologies I misread that...  

 

Perhaps this is what you're looking for?  I'm not very experienced with WRS so again, apologies if you looked here already.

https://www.ptc.com/support/-/media/support/refdocs/Windchill_REST_Services/2,-d-,6/wrs.pdf?sc_lang=en (Excerpt from Page 115)

Retrieving the Latest Version of an Entity
You can retrieve the latest version of an entity using the custom query option
ptc.search.latestversion. The option takes true or false as input
value.
When you specify the query option as true, it limits the search results to retrieve
only the latest version of the entity.
If the query option is specified as false, the search results retrieve the latest
iteration of each revision for the entity.
For example, the following URL retrieves the latest version of the parts:
GET /Windchill/servlet/odata/ProdMgmt/Parts?$filter=
startswith(Name,'Axle')&ptc.search.latestversion=true
The following rules apply to ptc.search.latestversion option:
• The value specified for latest version in the query option gets precedence over
the value set for Latest Version Search preference in Windchill.
• If the query option is not specified in the request URL, the value specified for
Latest Version Search preference in Windchill is used.
• If the query option is not specified in the request URL and the Latest Version
Search preference is not explicitly set

3-Newcomer
February 25, 2025

Hi, I'm curious to know whether you have found answer for retrieving the latest revision for all the UsedBy entities!