Skip to main content

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!

Hi Raya,

I think you want something like this:


// Get reference to our Application model<br>var appModel = skuid.$M('Application');&nbsp; <br>// Get reference to the first row<br>var appRow = appModel.getFirstRow();&nbsp; <br>// Log current status<br>var currentStatus = appRow.genesis__Status__c;&nbsp;<br>console.log('Current Status: ' + currentStatus);&nbsp; <br>// Call Apex web service to get latest pricing<br>try {<br>&nbsp; &nbsp; var result = sforce.apex.execute(<br>&nbsp; &nbsp; &nbsp; &nbsp; 'genesis.SkuidPricingCtrl',<br>&nbsp; &nbsp; &nbsp; &nbsp; 'generatePricing', {&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; applicationId : appRow.Id&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; );<br>&nbsp; &nbsp; console.log(result);&nbsp;<br>} catch (err) {<br>&nbsp; &nbsp; console.log('Error getting pricing: ' + err.description);<br>}&nbsp;<br><br>// NOTE: Both the row update and save could be performed in the Action Framework <br>// Update pricing status<br>appModel.updateRow({<br>&nbsp; &nbsp; Id: appRow.Id<br>}, {<br>&nbsp; &nbsp; genesis__Status__c: "NEW - PRICING GENERATED"<br>}); <br>// Save updates<br>appModel.save({<br>&nbsp; &nbsp; callback: function (result) {<br>&nbsp; &nbsp; &nbsp; &nbsp; if (result.totalsuccess) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;alert('New Quote Id: ' + appRow.Id);&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; } else {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert('Error: ' + result.insertResults[0]);&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log(result.insertResults[0]); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>});<br>&nbsp;<br>// Why are you doing this?<br>window.location.reload();&nbsp;




AWESOME! It is working !Thank you!


Reply