0

This is the error shown when I click on javascript button

Code which is working

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
window.open('/apex/transferrequest?id={!Case.Id}');

Code which is not working

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
if({!Case.Status}  =  'Closed'){
    alert('Case is Closed cannot update.');
}
else{
    window.open('/apex/TransferRequest?id={!Case.Id}')
}

If statement is being validated alert is shown, but there is some issue with else. What could be the possible solution.

1

In any programming language:

  1. = means Assignment
  2. == means Comparison

Also JavaScript is Dynamically typed programming languages, so you have to be careful while comparison. Status should be in quotes!

So, try changing:

if({!Case.Status}  =  'Closed')

to:

if("{!Case.Status}" == "Closed")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.