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
Paul DevenportPaul Devenport 

Anyone know what kind of syntax the URL section is on a custom button?

Anyone know what kind of syntax the URL section is on a custom button?  (and what context variables are available to it)  Is it Apex or VisualSource syntax or something else?  I want to add some logic like this, but it is not working:  {!URLFOR("/apex/CustomAttachment?id=" + (Contact!=null?Contact.Id:Opportunity.Id)}
 
I select Behavior: "Execute in existing window"
Content Source:  "URL"
pconpcon
The problem is that you are using URLFOR incorrectly.  You can do one of two things

Drop the URLFOR
/apex/CustomAttachment?id={!IF(NOT(ISBLANK(Contact)), Contact.Id, Opportunity.Id)}

Or, use the URLFOR correctly
 
{!URLFOR("/apex/CustomAttachment", IF(NOT(ISBLANK(Contact)), Contact.Id, Opportunity.Id))}

You should be able to use $Page.CustomAttachment instead, but I couldn't get it to work with my quick test.
Paul DevenportPaul Devenport
Thanks.  One strange thing is that inside of the IF/NOT/ISBLANK functions, Contact/Opportunity objects don't seem to be visible.  It gives me an error on "Contact".
pconpcon
What object are you creating this button for?