Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hi,
I need to trigger a windchill workflow from Thingworx. I think it's right way to expose this function through OData rest service in windchill.
The logic of WRS function is implemented by Javascript, which I don't understand and don't know where to find the document of API, I have no idea of how to implement my logic. Please help.
Below is sample code from Windchill Rest Service User Guide.
function function_GetCostlyParts(data, params) { var ArrayList = Java.type('java.util.ArrayList'); var EntityCollection = Java.type('org.apache.olingo.commons.api.data.EntityCollection'); var parts = data.getProcessor().readEntitySetData(data); var partEntityMap = data.getProcessor().toEntities(parts, data); var partEntities = new ArrayList(partEntityMap.values()); var entityCollection = new EntityCollection(); for(var i = 0; i < partEntities.size(); i++) { var partEntity = partEntities.get(i); var partCostProperty = partEntity.getProperty('DevelopmentCost'); if(partCostProperty) { var partCost = partCostProperty.getValue(); if(partCost && partCost > 0.10) { entityCollection.getEntities().add(partEntity); } } }
Thanks & Best Regards
Tom
Solved! Go to Solution.
I checked Windchill REST Services guide, there is a lot of information about how to create a new domain from page 62.
e.g.
to: Windchill/codebase/rest/custom/domain/DocMgmt/v1/entity
function action_uploadStage1Action(data, params) { // call method in ContentHolderEntityDelegate var ContentHolderEntityDelegate = Java.type("com.ptc.odata.windchill.entity.service.ContentHolderEntityDelegate"); return ContentHolderEntityDelegate.uploadStage1Action("document", data, params); }
Thank's Ivan.
Hi, you can investigate OData using Windchill URL: https://wnc-host/Windchill/servlet/odata
This URL display OData schema (all the services, and the entity type)
By each url, you can see details e.g
https://wnc-host:2443/Windchill/servlet/odata/v3/ProdMgmt
I don't see REST service for Workflow, but you can easily implement your own domain.
Thanks for your help. I can easily implement workflow related function by Java, but it's difficult for me to implement it by JavaScript, and I don't know where to find API document. So it's not easy implement my own domain.
Best Regards
Tom
I checked Windchill REST Services guide, there is a lot of information about how to create a new domain from page 62.
e.g.
to: Windchill/codebase/rest/custom/domain/DocMgmt/v1/entity
function action_uploadStage1Action(data, params) { // call method in ContentHolderEntityDelegate var ContentHolderEntityDelegate = Java.type("com.ptc.odata.windchill.entity.service.ContentHolderEntityDelegate"); return ContentHolderEntityDelegate.uploadStage1Action("document", data, params); }
Thank's Ivan.
Thanks. I got your point, will try it later.
Best Regards
Tom