cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

We are happy to announce the new Windchill Customization board! Learn more.

How can I customize an odata service to start workflow in windchill?

weli
12-Amethyst

How can I customize an odata service to start workflow in windchill?

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

1 ACCEPTED SOLUTION

Accepted Solutions

I checked Windchill REST Services guide, there is a lot of information about how to create a new domain from page 62.

 

e.g.

  • Copy: Windchill/codebase/rest/ptc/domain/DocMgmt/v1/entity 

to:  Windchill/codebase/rest/custom/domain/DocMgmt/v1/entity

  • Copy your java class to windchill codebase
  • Change js file content like: 

 

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);
}

 

  • Restart Windchill, 
  • Validate schema output for new domain, if it is correct try to invoke new REST service.

Thank's Ivan.

View solution in original post

4 REPLIES 4

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.

weli
12-Amethyst
(To:ivan_feofilov)

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.

  • Copy: Windchill/codebase/rest/ptc/domain/DocMgmt/v1/entity 

to:  Windchill/codebase/rest/custom/domain/DocMgmt/v1/entity

  • Copy your java class to windchill codebase
  • Change js file content like: 

 

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);
}

 

  • Restart Windchill, 
  • Validate schema output for new domain, if it is correct try to invoke new REST service.

Thank's Ivan.

weli
12-Amethyst
(To:ivan_feofilov)

Thanks. I got your point, will try it later.

 

Best Regards

Tom

Top Tags