Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
So basically i have a service which takes some ID (Number) as input and gives the details of that specific ID. The given details of the output parent infotable are:
number
deeplink
relatedIssues
owner
createdDate
daysOpen
targetCloseDate
So this "relatedIssues" property is another infotable which has another infotable as a property called "fieldData"
and i want to pick the property "CreatedOn" of the fieldData infotable and compare it with the "createdDate" property of the parent infotable. And parse it to have the difference as an output of the service alongside to display it later.
It is quite hard to follow this description, also there is no clear question - what do you want to know?
If you have nested infotables, each of them can have multiple rows, so you will have to iterate through all rows of the nested infotables to make the comparison with the parent table.
Yes the thing you have mentioned, iterating through the rows of nested infotables to access a property in the child infotable.
it would go something like this, but it's still pretty much guesswork
parentInfoTable.rows.toArray().forEach(row=>{
let relIssues=row.relatedIssues;
relIssues.rows.toArray().forEach(issuesRow=>{
let fData=issuesRow.fieldData;
fData.rows.toArray().forEach(fdataRow=> {
let difference=row.createdDate-fdataRow.CreatedOn;
// do something with the difference
});
});
});
This does not include the necessary error-checking you would need for robust code and assumes all nested infotables have multiple rows.
Thanks for the reply this is the code, i have logged the value here :
Also the value of is row.createdDate = Thu Feb 08 2024 10:00:33 GMT-0000 (UTC), and fdataRow.CreatedOn =undefined, i think there is some problem the way i am parsing the value.
This means one of the values is not a Date. You should log valueOne and valueTwo then you see which one. Maybe your date string include spaces or have a format that can't be parsed. Also note that row.createdDate is missing the "T".
Check here which date format is supported: https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date-time-string-format
i logged the values and got this as a response
Yeah so now you removed the "new Date" part, but as you can see, CreatedOn is empty in your infotable, so you can't make that subtraction. You need to decide how you want to handle that case.
I checked in on the values and i was able to get the value and i am getting the final output what i required as well, this is the final code for it:
"timeDifference" would be the string argument not a variable so you'd have to put that in quotes: 'timeDifference'
For BaseType I would use the proper spelling, always in capitals, so 'NUMBER'
Also note that
let localInfoTable = data;
will not create a copy of the table but just another reference to the same infotable.
Sure, will look into this, Thanks a lot again for the help.