function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rony57Rony57 

JavaScript on custom button

Hello  Guys,
                 I  am having a trouble while running a JS on my button . I have a button name Make Available on my detail page and there is a pick list name status which is by-default Pending. Whenever user click on Make Available button then the status would automatically change from pending to Available. Following is my code :-
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
var pro = new sforce.SObject('SPBE__Property__c'); 
pro.Id = '{!SPBE__Property__c.Id}'; 
pro.SPBE__Status__c= 'Available'; 
var result = sforce.connection.update([pro]); 
if(result[0].success=='true'){ 
    alert('The Status Updated Successfully'); 
} 
else{ 
    alert('The Status Updated Unsuccessfully'); 
} 
window.location.reload(true);
}


 
Prashanth KapparapuPrashanth Kapparapu
This code worked for me!!

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")} 

var acc = new sforce.SObject("Account"); 
var F_Flag = '{!Account.F_Submit__c}'; 
acc.id='{!Account.Id}'; 

if(F_Flag == true) acc.F_Submit__c="false"; 
else acc.F_Submit__c="true"; 

result=sforce.connection.update([acc]); 
window.location.href = window.location.href;