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);
rowsToUpdatemthis.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
Page 1 / 1
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:
rowsToUpdatesthis.Id] = { Client_Relationship_Name__c: full_name };
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.