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
Anna Rudenko 9Anna Rudenko 9 

Javascript button Object is not defined

We have Account & its child object CSP Passport (master - detail relationship). 
If child passport already exists (one or many), show the user the message to go and clone existing record. 
If there is no child object - the button on Account shall go to standard creation of this child record. The only field I would like to get prepopulated is Account ID (being master-detail relat.).
Now I am getting error "Account is not defined".
Button is created on Account.
{!REQUIRESCRIPT("/soap/ajax/43.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/43.0/apex.js")}
if(Account.CSP_Passport_Count__c>= 1) {
    alert("Please clone the latest created CSP Passport form");} 
else {
      window.open('a4e/e?CSP_Passport_Count__c.AccountId ={!Account.Id}');
}

Thanks in advance for all the suggestions
 
GovindarajGovindaraj
Hi Anna,

Please replace 3rd line like below.
if( "{!Account.CSP_Passport_Count__c}" >= 1)
it couldn't able to recognize the Account as that should be in formula expression.

Please let us know if that helps.

Thanks,
Govindaraj.S
collection chatcollection chat
Thank You for share great solution about that... (https://chat-roulette.co/)