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
atlantisatlantis 

How to populate relative VF page link into URL custom field

Hi Guys,

 

Supposing I created a custom field with URL type on any object, I need to set the default value which navigates to a VF page.

 

What I populate is i.e. '/apex/helloworld'. But when the link is clicked on detail page, it takes me to a new place http://apex/helloworld  which is not existing.

 

Does anybody know how to insert relative instance name before the '/apex/helloworld', such as global variables?

 

Regards,

Atlantis

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Rather than hardcoding the server instance, you can determine it from the $API field:

 

 

HYPERLINK(LEFT($Api.Partner_Server_URL_140, FIND(".com/",$Api.Partner_Server_URL_140)+3) + '/apex/HelloWorld', 'HelloWorld')

 

 

All Answers

Pradeep_NavatarPradeep_Navatar

In my opinon, you can not give a reference of the page url in default value. You can keep default value as a  blank and after giving the value of url field https://ap1.salesforce.com/apex/helloworld it will take you to the helloworld page.

 

You can also use formula field instead of url type field and use the syntax provided below :

 

HYPERLINK("https://ap1.salesforce.com/apex/helloworld" ,'testlink')

 

Hope this helps.

atlantisatlantis

Thanks Pradeep.

 

In my case, i have to choose the first option as you said.

 

However, the real instance server name is not what i expected, because we need to migrate this to another environment.

 

Can I use placeholder instead of the real instance name i.e. ap1.salesforce.com?

 

 

Regards,

Atlantis

bob_buzzardbob_buzzard

Rather than hardcoding the server instance, you can determine it from the $API field:

 

 

HYPERLINK(LEFT($Api.Partner_Server_URL_140, FIND(".com/",$Api.Partner_Server_URL_140)+3) + '/apex/HelloWorld', 'HelloWorld')

 

 

This was selected as the best answer
atlantisatlantis

That is fantastic, Bob.