Skip to main content

I have tried what feels like endless variations of this snippet, but for some reason I can’t get this snippet to update my rows correctly. I have commented out each line so as to hopefully describe exactly what I’m doing:

Thanks in advance for any/all help, and please pardon any obvious oversights…still learning.


var params = argumentsu0];<br>var step = params.step; var $ = skuid.$; var models = skuid.model.map(); // Model of Goals to be updated var newGoals = models.Goals_Placeholder; // Context model which will be used to query and store the Template Goal // that matches each goal in my newGoals model during iteration var matchingTemplateGoal = models.ContextGoal; // For each New Goal, query it's matching Template Goal and // update the value of the Template_Goal__c lookup with the Id of the matching Template Goal $.each(newGoals.data,function(){ // Get reference to filterable condition on Context Goal model var contextgoalNameCondition = matchingTemplateGoal.getConditionByName('GoalName'); // Set condition of ContextGoal model to match this current goal's Goal__c value matchingTemplateGoal.setCondition(contextgoalNameCondition, this.Goal__c ); // Refresh Context Goal model, now that the condition has been set $.when(matchingTemplateGoal.updateData()).then(function(){ // Potential alternative for refreshing Context Goal model //matchingTemplateGoal.updateData(); // Get value of Context Goal Id var matchedGoalId = matchingTemplateGoal.getFieldValue(matchingTemplateGoal.getFirstRow(), 'Id'); // Update this current goal's Template Goal lookup with the Id of Context Goal var row = newGoals.updateRow(this, { Template_Goal__c: matchedGoalId}); }); });<br>




Hey Conlan,

I’m not sure I can totally diagnose your snippet issues, but here are some ideas: 

  • Using skuid.model.getModel()—shortcut skuid.$M()—and the getRows() API is typically the best way to work with model data you’ll be updating. The map() API and a model’s data property may sometimes work, but can lead to issues. They’re more useful for looking at data than updating it.
  • Is setting the reference to the ContextGoal’s condition inside the iteration necessary? Perhaps try it outside of that.
  • By setting your updateRow() to a variable, it may not be getting invoked as intended. Try removing the variable assignment.
I’m not a JS expert, so you may need to tinker more. But give something like this a shot:


var $ = skuid&#46;$;<br />var newGoals = skuid&#46;$M('Goals_Placeholder')<br />var matchingTemplateGoal = skuid&#46;$M('ContextGoal')<br />var contextGoalCondition = matchingTemplateGoal&#46;getConditionByName('GoalName');<br />$&#46;each(newGoals&#46;getRows(), function() {<br />&nbsp; matchingTemplateGoal&#46;setCondition(contextGoalCondition, this&#46;Goal__c)<br />&nbsp; $&#46;when(matchingTemplateGoal&#46;updateData())&#46;then(function(){<br />&nbsp; &nbsp; var matchedGoalId = matchingTemplateGoal&#46;getFieldValue(matchingTemplateGoal&#46;getFirstRow(), 'Id');&nbsp; &nbsp;&nbsp;<br />&nbsp; &nbsp; newGoals&#46;updateRow(this, {Template_Goal__c: matchedGoalId});<br />&nbsp; })<br />})

Hey Cody,

Sorry to be so slow and unresponsive, this project got put on the backburner. Thanks for your help on this. I’ve tried out your suggestions, and am still not getting the snippet to function as expected.

It appears the issue is with the row updates. The condition sets fine within the iteration, and I was able to print out each matching Goal Id to the console. 

However, for some reason it’s not updating my newGoals records.

Any further helping hand you could provide is much appreciated.


var params = argumentsu0]; var step = params.step; var $ = skuid.$; // Model of Goals to be updated var newGoals = skuid.$M('Goals_Placeholder'); // Context model which will be used to query and store the Template Goal // that matches each goal in my newGoals model during iteration var matchingTemplateGoal = skuid.$M('ContextGoal'); // Get reference to filterable condition on Context Goal model var contextgoalNameCondition = matchingTemplateGoal.getConditionByName('GoalName'); var rowsToUpdate = {}; // For each New Goal, query it's matching Template Goal and // update the value of the Template_Goal__c lookup with the Id of the matching Template Goal $.each(newGoals.getRows(),function(){ // Set condition of ContextGoal model to match this current goal's Goal__c value matchingTemplateGoal.setCondition(contextgoalNameCondition, this.Goal__c ); // Refresh Context Goal model, now that the condition has been set $.when(matchingTemplateGoal.updateData()).then(function(){ // Get value of Context Goal Id var matchedGoalId = matchingTemplateGoal.getFieldValue(matchingTemplateGoal.getFirstRow(), 'Id'); //update this row with Matched Template Id rowsToUpdateUthis.Id] = { Template_Goal__c: matchedGoalId }; }); }); // update &amp; save newGoals with Matched Template Id newGoals.updateRows( rowsToUpdate ); newGoals.save();&nbsp; &nbsp;&nbsp;