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
Book_GuyBook_Guy 

Alert Pulling the value from a field

Hi All,

 

When a button is clicked if there are any conversion issues the following alert code runs:

alert('Conversion Issues');

}

 

Instead of displaying the text  'Conversion Issue'  I would like it to pull the value from the !Lead.Conversion_Issues__c field.

 

TIA

 

--David

craigmhcraigmh

alert('{!yourLeadControllerVariable.Conversion_Issues__c}');

Book_GuyBook_Guy

How would I set up the variable in Apex?

 

--David

craigmhcraigmh

Are you using the Lead object as the standard controller, or are you using a custom one?

Book_GuyBook_Guy

The lead object.

craigmhcraigmh

So it's the record in your controller that you're working with.

 

For example, if this is in your controller:

 

    private ApexPages.StandardController controller { get; set; }
    public Lead l;
    public YourClass(ApexPages.StandardController controller) {
        this.controller = controller;
        this.l = (Lead)controller.getRecord();
    }

 Then the variable would be l.

Book_GuyBook_Guy

Craig, 

 

That's for the help.  But I'm still a bit unclear.  Below is the code on our button:

 

if('{!Lead.Conversion_Ready__c}' == true){
window.location.href = '/apex/ConvertLead?id={!Lead.Id}';
}
else {
alert('Conversion Issues');
}

 

Can I assign that varible within this code or do I need to create a separate class?

 

--David