Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
I have added infotable property in userextensions. When iam updating every index of infotable, this folloeing error is poping up. How to update each index of infotable rows which is already created in userextension.
Error: JavaException: java.lang.ClassCastException: com.thingworx.types.InfoTable cannot be cast to com.thingworx.types.collections.ValueCollection
Hi @AP_10343008
Based on your error message: You are trying to add ValueCollection to InfoTable variable.
It will be helpful if you post your code to debug it
The below script is used to add a new row to user extension
var infoTableValue = Users["Administrator"].testp;
infoTableValue.AddRow({
f1: "t1",
f2: "t2"
});
infoTableValue.AddRow({
f1: "t3",
f2: "t4"
});
Users["Administrator"].testp = infoTableValue;
var result = Users["Administrator"].testp;
To update infotable value
var infoTableValue = Users["Administrator"].testp;
for(var i = 0 ; i < infoTableValue.length; i++)
{
if(infoTableValue.rows[i].f1 === "t1")
{
infoTableValue.rows[i].f2 = "Changed";
}
}
Users["Administrator"].testp = infoTableValue;
var result = Users["Administrator"].testp;
/VR
Example: I have 15 rows in Users["Administrator"].testp
Based on change event, iam running same service 15 times to update each row[index] of infotable.
So i need a code to update only particular row in user extension property directly not the full infotable.
I tried the below code by directly passing index number of infotable but it doesnt worked.
newEntry.AddRow({colA : "A", colB : "B"});
Users["Administrator"].testp[1] = newEntry;
Hi @AP_10343008
If you know the index of the row
// Get value from User extension and store it in InfoTable
var infoTableValue = Users["Administrator"].testp;
// update row value based on index
infoTableValue.rows[INDEXNUMBER].f1 = "directValue";
// Update User extension value
Users["Administrator"].testp = infoTableValue;
// Return result to validate data
var result = Users["Administrator"].testp;
/VR