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
mbbendermbbender 

Can't get opportunity information

I'm new to this salesforce development thing so work with me here.
 
I added a custom link on the opportunity that is set to execute some javascript. In the javascript that is to be executed I would like to use information specific to the opportunity where the link was clicked.
 
How do I get the information such as opportunity name and opportunity contacts inside my javascript?
mbbendermbbender

To clarify,

I want to be able to do things specific to the opportunity on which the custom link was clicked.  How can I find the opportunity record that is the one on which the custom link was clicked?

SuperfellSuperfell
When you setup the custom link, there's a drop down list of merge fields that you can add to the URL, this can be used to pass the recordId or other information from the current opportunity on the URL to your code.
mbbendermbbender

Thanks for the response.  The way I have it setup is that the Display Type is Detail Page Button, Behavior is Execute JavaScript and content Source is OnClick JavaScript.  I don't see where I can add merg fields to the URL. And when I try to use a merge field it gives me a syntax error or something everytime.  Here is an example of my code:

alert({!Opportunity.Id});

When I click the button I get:

missing ) after argument list

mbbendermbbender
Ok, so all you had to do was put "" around the {!Opportunity.Id}.
 
alert("{!Opportunity.Id}") works just fine.