Answered
Copying a value to all rows within a collection
Hi,
Please can you advise what expression / function I can use to automatically copy a value from the first row in a collection to all of the rows. I've attached a screen shot where the parameter entity 'Description 2' is changed to 'Bristol'. I would like 'Bristol' to then be copied to all rows in the table, but to then also allow the user to change individuals fields after without it then changing all fields.
Thanks
Amber
Files:
Copy data in co...
Dear Amber
One way to implement this functionality would be to add a button below the table and write an expression that is executed "On Click" of the button.
The expression would basically get the Description from the first row and set it to the remaining rows of the table. Here is an example script. You can modify it as per your data model.
var allRecords = <XPath of your collection>;
var firstRecord = allRecords.get(0);
var firstCode = firstRecord.getXPath("Description2.Code"); // assuming the description entity has Code as one of the attributes.
for (var i=1; i<allRecords.size(); i++){
var thisRecord = allRecords.get(i);
thisRecord.setXPath("Description2",CHelper.getEntityAttrib("Description2","idDescription2","Code =
'"+firstCode+"'"));
}
The statement setXPath above will set the "Description2" by using the "ID" (Bizagi generated) of the first row. The above code snippet is assuming you have a "Code" as one of the attributes in your "Description2" entity. Please feel free to modify it as per your needs.
Hope this helps!
Best Regards
Comments have been locked on this page!