You need to sign in to do that
Don't have an account?
Bogdan Pascu
Validation rule on custom button Hi
I have this custom button with Javascript that is working perfectly fine:
{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/23.0/apex.js")}
if ({!pba__Offer__c.pba__SystemIsCancelled__c}) {
alert("{!$Label.pba__Offer_ErrorAlreadyCancelled}");
} else {
if (confirm("{!$Label.pba__Offer_ConfirmCancellation}")) {
var updateSobject = new sforce.SObject("pba__Offer__c");
try {
updateSobject.Id = "{!pba__Offer__c.Id}" ;
updateSobject.pba__SystemIsCancelled__c = true;
result = sforce.connection.update([updateSobject]);
if (result[0].getBoolean("success")) {
location.reload(true);
} else {
alert("{!$Label.pba__Generic_ErrorOccured}: " + result[0].errors.message);
}
} catch(e) {
alert("{!$Label.pba__Generic_ErrorOccured}: " + e);
}
}
}
I want to include an additional line to this code, can you please help me on where this new line should go:
if (ISBLANK({!pba__Offer__c.Offer_canceled_comments__c}) {
alert ("Please specify the reason why the Offer has been canceled!!!!");
} else {
{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/23.0/apex.js")}
if ({!pba__Offer__c.pba__SystemIsCancelled__c}) {
alert("{!$Label.pba__Offer_ErrorAlreadyCancelled}");
} else {
if (confirm("{!$Label.pba__Offer_ConfirmCancellation}")) {
var updateSobject = new sforce.SObject("pba__Offer__c");
try {
updateSobject.Id = "{!pba__Offer__c.Id}" ;
updateSobject.pba__SystemIsCancelled__c = true;
result = sforce.connection.update([updateSobject]);
if (result[0].getBoolean("success")) {
location.reload(true);
} else {
alert("{!$Label.pba__Generic_ErrorOccured}: " + result[0].errors.message);
}
} catch(e) {
alert("{!$Label.pba__Generic_ErrorOccured}: " + e);
}
}
}
I want to include an additional line to this code, can you please help me on where this new line should go:
if (ISBLANK({!pba__Offer__c.Offer_canceled_comments__c}) {
alert ("Please specify the reason why the Offer has been canceled!!!!");
} else {
All Answers
if (confirm("{!$Label.pba__Offer_ConfirmCancellation}")) {
Don't forget to add a closing '}' at the end.
I guess this is what you are looking for:
Kindly mark the solution as the answer if it works
Veenesh
I have tried with your code and I still get the folowing error:
A problem with the OnClick JavaScript for this button or link was encountered:
Unexpected token {
Veenesh
Now I get this error:
A problem with the OnClick JavaScript for this button or link was encountered:
ISBLANK is not defined
This will work, you were missing a ")" after If statement.
Veenesh
I am stil getting the same error
Try to replace this line: With this:
I have tried replacing the line of code with the new one and now I get this error:
A problem with the OnClick JavaScript for this button or link was encountered:
Unexpected token ==
Many thanks, it is working perfectly.
Please mark the answer so others can also benefit from that. Thanks!