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>