+ Start a Discussion
Charni WigginsCharni Wiggins 

URL does not exist error for custom button with logic

I would like to only allow access to the link on this button if users profile name contains Manager, I can't quite get it to work though, currently getting 'url does not exist error' even without the contains function... 

Button:

{!IF( $Profile.Name == 'System Administrator', '/apex/echosign_dev1__AgreementTemplateProcess?masterId={!Contact.Id}&templateID=a8r0Y000000Cbld&emailaddress={!Contact.TR1__Secondary_Email__c}', null)}
 
RD@SFRD@SF
Hi Charni,

Please, can you share the screenshot of the button definition, would be helpful in finding the issue?

RD
 
Charni WigginsCharni Wiggins
User-added image

thank you :)
RD@SFRD@SF
Hi Charni,

1. I see that you have mentioned the Salesforce instance, in the button definition. Can you double check that the instance is correct.
2. Also, can you check if the visualforce page you are redirecting to has a prefix, you might have to add the prefix to the URL as 
/apex/prefix_VFpageName?parameters

3. What is the URL on the screen where you get the error that the URL does not exist? (Copy paste the browser URL value from the error screen. It could be that the URL is not formed correctly.)

 
Charni WigginsCharni Wiggins
I actually posted the wrong screenshot, sorry... User-added image

the error url: https://cobwe.my.salesforce.com/one/apex%2Fechosign_dev1__AgreementTemplateProcess%3FmasterId%3D%7B%21Contact.Id%7D%26templateID%3Da8r0Y000000Cbld%26emailaddress%3D%7B%21Contact.TR1__Secondary_Email__c%7D

this is the namespace prefix (this is what you mean right?): 
echosign_dev1
RD@SFRD@SF
Charni,

1. The prefix is correct.
2. From your error URL, if you see the contact id and the contact email address are not being set dynamically but instead, it is being taken as a string. I think this is what is causing the issue.
3. Also, it seems we cannot use functions in URL button, one way is to move this to a formula field with the return type as URL and then set the URL value in the button.

This is the link to a similar post
https://success.salesforce.com/answers?id=90630000000h2rgAAA

Hope it helps
RD
RD@SFRD@SF
Charni,

Just an update, while using the formula field in the URL put it inside a URLFOR formula. Like below
{!URLFOR(URL_formula__c)}
Charni WigginsCharni Wiggins
how do you mean? {!URLFOR(URL_formula__c)} will go in the if statement instead of the url, where the url_formula__c field is a formula? 
Charni WigginsCharni Wiggins
So I have done that, now I am having trouble passing the contact ID (current record ID) through... ?
RD@SFRD@SF
Hi Charni,

Can you share the formula which you wrote for the overall link.
Charni WigginsCharni Wiggins

Hi, Sure...

 

{!IF( $Profile.Name == 'System Administrator', URLFOR( Contact.Adobe_Perm_formula__c, echosign_dev1__SIGN_Agreement__c.echosign_dev1__RecipientId__c ), null)}

Where the Adobe Perm Formula field on Contact is: 

"https://cobweb.lightning.force.com/apex/echosign_dev1__AgreementTemplateProcess?masterId=Contact.Id&templateID=a8r0Y000000Cbld&emailaddress=Contact.TR1__Secondary_Email__c"