I have a JavaScript button that is meant to set SAPReleased__c = "True" whenever it is pushed. Now this should only work when Approved__c is True. This is my current code which isn't working.. Any thoughts?
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
//Query the record from the DB.
var result = sforce.connection.query("Select Name,Approved__c,SAPReleased__c,Sample_Fullfillment_Channel__c from Sampling__c where Id=\'{!Sampling__c.Id}\'");
var records = result.getArray("records");
//Since we are dealing with one record per button we can just take the 1st val from
//the records array.
var Sampling = records[0];
if(Sampling.Approved__c){
Sampling.SAPReleased__c = 'TRUE';
Sampling.Sample_Fullfillment_Channel__c = 'SAP';
}
else{
alert('Sample must be approved before it can be booked.');
}
result = sforce.connection.update([Sampling]);
window.location.reload();
So update to my code I changed it from "True" to 1, in which it appears that it is getting inside of my Loop, now I just need to figure out how to set SAPReleased__c == True. It isn't getting updated how I have it now.
It is running but it isn't setting my check box to "True" Is this right?
Sampling.SAPReleased__c = true;