You need to sign in to do that
Don't have an account?
Sean O'Connell
Help with Button Code
I am crearting a pretty simple button but I can not figure out how to get i to work correctly here is what I have
{!REQUIRESCRIPT("/soap/ajax/34.0/connection.js")}
if ({!Inspection__c.Appointment_Date__c <= TODAY()})
{
alert("Its Past The Appointment Date and Can not be Canceled");
}
else{
var newRecords = [];
var i = new sforce.SObject("Inspection__c");
i.id ="{!Inspection__c.Id}";
i.queue__c = 'Canceled';
i.ownerid = '00G37000000hecW'
newRecords.push(i);
result = sforce.connection.update(newRecords);
window.location.reload();}
This Script works in every sceniario other then if Inspection__c.Appointment_Date__c is blank. I am getting an error
"A problem with the OnClick JavaScript for this button or link was encountered:
Unexpected token {"
What I want to happen is the field is empty/Null I want it to run the code not the alert.
Thanks in Advance
Sean
{!REQUIRESCRIPT("/soap/ajax/34.0/connection.js")}
if ({!Inspection__c.Appointment_Date__c <= TODAY()})
{
alert("Its Past The Appointment Date and Can not be Canceled");
}
else{
var newRecords = [];
var i = new sforce.SObject("Inspection__c");
i.id ="{!Inspection__c.Id}";
i.queue__c = 'Canceled';
i.ownerid = '00G37000000hecW'
newRecords.push(i);
result = sforce.connection.update(newRecords);
window.location.reload();}
This Script works in every sceniario other then if Inspection__c.Appointment_Date__c is blank. I am getting an error
"A problem with the OnClick JavaScript for this button or link was encountered:
Unexpected token {"
What I want to happen is the field is empty/Null I want it to run the code not the alert.
Thanks in Advance
Sean
I have update your code as per your requirement.
Hope it helps you.
Thanks,
Anjith kumar.