Skip to main content
12-Amethyst
Question

OData Filter by Custom Attribute

Version: Windchill 12.1

 

Use Case: I am attempting to do an OData call to retrieve parts filtered by a custom attribute on a part. How do I do a GET request with a $filter that allows me to filter a custom attribute?


Description:

 

Attempted URL:

Error message: 

 

{
 "error": {
 "code": null,
 "message": "The property 'MY_ITEM_NUMBER', used in a query expression, is not defined in type 'PTC.ProdMgmt.Part'."
 }
}

 

 

URL's I've tried that do not work:

Error message:

 

{
 "error": {
 "code": null,
 "message": "The URI is malformed."
 }
}

 

 

Other URLs:

 

I tried following the steps here without success: https://community.ptc.com/t5/Windchill/How-to-fetch-part-list-using-custom-attribute-via-Windchill/m-p/969188#M81973

 

Is this possible? Seems like it should be a common thing to do, but I haven't found much help online or in the KBs. Thanks for the help in advance!

6 replies

Catalina
Community Manager

Hi @CB_12625553 

Thank you for your question. 

Your post appears well documented but has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help.

Also, feel free to add any additional information you think might be relevant. It sometimes helps to have screenshots to better understand what you are trying to do.

 

Best regards,

Translate
Catalina | PTC Community Manager
12-Amethyst

Hi,

 

Please map the property MY_ITEM_NUMBER in PartsExt.json file in the custom rest folder. You could be able to filter based on custom attribute. Refer Adding Custom Properties to Entities in PTC Domains.

 

PartsExt.json

{
"extends": "Part",
"attributes": [
{
"name": "MY_ITEM_NUMBER",
"internalName": "MY_ITEM_NUMBER",
"type": "String"
}
]
}

 

Post the above step you can apply filter like below

https://company.ptcmscloud.com/Windchill/oauth/servlet/odata/ProdMgmt/Parts?$filter=contains(MY_ITEM_NUMBER,  '12345')

Translate
6-Contributor

How to do same for subtype eg Part-->Wheel(Subtype)

Translate
Fadel
23-Emerald II

for subtype you should have endPoints OOTB LIKE BELOW  

 

Translate
Buiꓘa
6-Contributor

have you tried this in subtype?

Translate