Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
I have created a service which takes an input by the name "objectData" and this is a data shape which has certain property and values like:
rootCauses
0containmentActions
daysOpen
workflowStatus
stepStatusTable
supplierTeam
adjustedCloseDate
actionStatus
workItems
Here in the service what i want to do is that pick any property and manipulate the data which the property holds, since this input objectData is the output of some other service and is binded to as the input of this service for manipulation. So far i have tried this code but i think it's incorrect :
@AV_10867476 teh input is an infotable or is a JSON object? Could you share a sample input.
Your code should work, if objectData is an infotable of the dataShape you described.
Here's a working sample:
// setting up a sample infotable using a system datashape
let it=DataShapes.RemoteServiceBinding.CreateValues();
it.AddRow({name:"aa",sourceName:"bb", timeout:1});
it.AddRow({name:"cc",timeout:2});
it.AddRow({name:"ee",sourceName:"ff", timeout:3});
// iterating and updating
for(let i = 0; i< it.length; i++){
let row = it.rows[i];
if("sourceName" in row ){
row.timeout=99;
}
}
//returning result infotable
result=it;
When iterating, I would prefer this notation for brevity, but yours is fine as well.
it.rows.toArray().forEach(row=>{
if (row.sourceName)
row.timeout=99;
});