problems with update of model

  • 1
  • Problem
  • Updated 3 years ago
I have a Client model where I need to update every record. Salesforce doesn't make this easy :(
Skuid helps.
I built a temp skuid page and loaded my client model.
then I wrote a snippet to take the currently in the "Client Full Name" field and update the "Client Relationship Name" field
 myModel = skuid.model.getModel('Client');rowsToUpdate = {};
full_name = "";
skuid.$.each( myModel.data, function(){
    full_name = this.Client_Full_Name__c;
    console.log(full_name);
    rowsToUpdate[this.Id] = { Client_Relationship_Name: full_name };
});

 updated_rows = myModel.updateRows( rowsToUpdate );
console.log(updated_rows.length + ' rows updated');
myModel.save({callback: function(result){
    if (result.totalsuccess) {
        // Get the 15-digit Id of our newly-saved George Bailey Contact,
        // which will have had its Id and other fields updated after save
        console.log('success');
        
    } else {
        console.log(result.insertResults);
        console.log(result.updateResults);
        console.log(result.deleteResults);      
    }
}});

when I run this all the names print out, and after a little wait I get "success"
if I inspect the "updated_rows" array, they all have the updated field.
if I do skuid.model.getModel('Client') and look at the data
it all has the updated field
but the table i'm using to display the data does not show the updated data
even if i recycle the page
i can't see what I'm missing
Photo of ktyler

ktyler

  • 9,244 Points 5k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,004 Points 20k badge 2x thumb
I'm guessing that you just forgot the "__c" at the end of Client_Relationship_Name, so it should be Client_Relationship_Name__c instead on this line:

rowsToUpdate[this.Id] = { Client_Relationship_Name__c: full_name };
(Edited)