+ Start a Discussion
Erik LarameeErik Laramee 

javascript - save record

Hey Folks,

We have a two step approval process for one of our objects. The first step uses the standard approval process and once approved, the second step uses an existing OnClick javascript button to set the final approval status. The button just does a page refresh showing the new value without saving the record. This is preventing me from using workflows that trigger off the final value.

Previously the standard process locked the record which I believe is why the code was written this way. It has since been changed to unlock the record, so saving it post standard approval will no longer be an issue. I would like to be able to modify this button to save the record, if possible, so that I can trigger workflows. Can someone help me with the code or point me in the right direction? This is the code for the button:

var connection = sforce.connection; 

var ConReqID ="{!Con_Req__c.Id}"; 
var ChangeOrderType ="{!Con_Req__c.Change_Order_Type__c}"; 
var status="{!Con_Req__c.Status__c}"; 

alert('Status should be Approved before pressing Approved By Customer Button'); 

else if (ConReqID && ConReqID != "") 

/* var ConReq = new sforce.SObject("Con_Req__c"); 
ConReq.Id = ConReqID; 
ConReq.Status__c = "Approved By Customer"; 
connection.update([ConReq]); */ 
sforce.apex.execute("ChangeOrderApprovalRequest","SendApprovalRequest", {id:ConReqID}); 
window.parent.location.href='/'+ConReqID ;