You need to sign in to do that
Don't have an account?
Rony57
Custom OnClick JavaScript Button to Update Status
I'm trying to create a custom OnClick JavaScript button that will update a Status field on my detail page from Pending to Available when clicked on button. Here is my follwing code:-
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var pro = new sforce.SObject('APPa__Tickets__c');
pro.Id = '{!APPA__Tickets__c.Id}';
pro.APPA__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);}
But when i click on the button it shows an error:Unexpected Token else. Help me out ..
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var pro = new sforce.SObject('APPa__Tickets__c');
pro.Id = '{!APPA__Tickets__c.Id}';
pro.APPA__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);}
But when i click on the button it shows an error:Unexpected Token else. Help me out ..
All Answers
There is one '}' missing in your script
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var pro = new sforce.SObject('APPa__Tickets__c');
pro.Id = '{!APPA__Tickets__c.Id}';
pro.APPA__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);}
A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'sf:API_CURRENTLY_DISABLED', faultstring:'API_CURRENTLY_DISABLED: API is disabled for this User', detail:{UnexpectedErrorFault:{exceptionCode:'API_CURRENTLY_DISABLED', exceptionMessage:'API is disabled for this User', }, }, }