Skip to main content

I currently have two models, Model A and B. I want the values from Model saved to one field on Model B.

I coded a button to pass condition values to Model A. Model A will have 3 different lines and different data in Field__c. I need to concatenate the values in Field__c on Model A and update one field on Model B. 

Does anyone know how I could achieve this?

So assuming that there is only one row in Model B that you want to store the field values from all rows in Model A into, this snippet should work:


var modelA = skuid.$M("ModelA");
var modelB = skuid.$M("ModelB");
var sourceField = "Field__c";
var targetField = "Target_Field__c";
// assuming you want to comma-separate the values, change this to something else if needed
var separator = ",";
modelB.updateRow(
modelB.getFirstRow(),
targetField,
modelA.getRows().map(function(row) {
return modelA.getFieldValue(row, sourceField, true);
}).join(separator)
);```

Thank you Zach this is great! I also found that if I use (JOIN_TEXT) as a formula within the action to update row works as well.


OHHH — using JOIN_TEXT is a great idea, love it.