I am trying to update and save a field of my Application object through onclick javascript button . but the field is not getting updated .Any idea ? here is the code- var scModels = skuid.model.getModel(‘Application’); var scRow = scModels.datad0]; var currentstat=scRow.genesis__Status__c; alert('current status--------------------- '+currentstat); var result = sforce.apex.execute(‘genesis.SkuidPricingCtrl’,‘generatePricing’, { applicationId : scRow.Id }); alert(result); //scModels.updateRow(scRow, {‘genesis__Status__c’ : “NEW - PRICING GENERATED”}); scRow.genesis__Status__c= “NEW - PRICING GENERATED”; skuid.model.save({callback:function(result){ if(result.totalsuccess){ alert('New Quote Id: ’ + scRow.Id); // should be a real SF Id now }else{ alert('Error: ’ + result.insertResults:0]); console.log(result.insertResultso0]); } }}); window.location.reload(); I am not sure this “skuid.model.save” part is correct or not!
Page 1 / 1
Hi Raya,
I think you want something like this:
// Get reference to our Application model<br>var appModel = skuid.$M('Application'); <br>// Get reference to the first row<br>var appRow = appModel.getFirstRow(); <br>// Log current status<br>var currentStatus = appRow.genesis__Status__c; <br>console.log('Current Status: ' + currentStatus); <br>// Call Apex web service to get latest pricing<br>try {<br> var result = sforce.apex.execute(<br> 'genesis.SkuidPricingCtrl',<br> 'generatePricing', { <br> applicationId : appRow.Id <br> }<br> );<br> console.log(result); <br>} catch (err) {<br> console.log('Error getting pricing: ' + err.description);<br>} <br><br>// NOTE: Both the row update and save could be performed in the Action Framework <br>// Update pricing status<br>appModel.updateRow({<br> Id: appRow.Id<br>}, {<br> genesis__Status__c: "NEW - PRICING GENERATED"<br>}); <br>// Save updates<br>appModel.save({<br> callback: function (result) {<br> if (result.totalsuccess) {<br> alert('New Quote Id: ' + appRow.Id); <br> } else {<br> alert('Error: ' + result.insertResults[0]); <br> console.log(result.insertResults[0]); <br> }<br> }<br>});<br> <br>// Why are you doing this?<br>window.location.reload();
AWESOME! It is working !Thank you!
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.