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
TsvetyTsvety 

Adding URL field that can be clicked in edit mode

Hi Experts!

I would like to add a detail link to a page layout that will be visible/clickable when a record is created/edited. Example:

User-added image

What I tried so far:
- creating a detail page link, but it is not visible in edit mode
- simple url field that is read only, but it is not clickable.

Is there any way to accomplish this?

Thank you!
Agustina GarciaAgustina Garcia
If you want to use Standard UI and just inclue the link on your object page layout, the only thing that comes to my mind is the creation of the URL field. You can set a default value on it and don't make it read only. Once you click on new or edit, as this is a field, you could modify it, but after saving any change, it would be clickable again. If you want to keep the value even on edit more, you can add a validation in a trigger in order to not modify the value.

The other option is to create a visualforce page and include the link (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_outputLink.htm)

Hope this helps.

 
TsvetyTsvety
Agustina, thanks for taking the time to reply.
Unfortunately if I have just a field it won't be clickable during edit mode.
And the visualforce page won't be an option because it can't be displayed in an edit mode.

The whole purpose of doing this is to be able to include a link to a policy in an edit/new mode. When a user creates a record, he/she will be able to click on the policy link and review the policy.

Can you think of another workaround?
 
Agustina GarciaAgustina Garcia
I was also thinking about creating a vf page with the outputlink and include the vf page in the layout, but the same, it only works on view mode. On edit mode, this readonly field disapear.

I would go for visualforce page althought maybe this is not a solution for you.

You can create a vf for Input Data
<apex:page standardController="ObjectA__c">
    <apex:form >
        <apex:sectionHeader title="ObjectA Input Data">
            <apex:pageBlock >
                <apex:pageBlockSection title="ObjectA Information">
                    <apex:inputField value="{!ObjectA__c.Name}"/>
                </apex:pageBlockSection>
                <apex:pageBlockSection title="Policy Information">
                    <apex:outputLink value="www.salesforce.com">Policy Information</apex:outputLink>
                </apex:pageBlockSection>
            </apex:pageBlock>
        </apex:sectionHeader>
    </apex:form>
</apex:page>
And override New and Edit button with it, so you get this:

User-added image

Then the same for Output Data
 
<apex:page standardController="ObjectA__c">
    <apex:form >
        <apex:sectionHeader title="ObjectA Output Data">
            <apex:pageBlock >
                <apex:pageBlockSection title="ObjectA Information">
                    <apex:outputField value="{!ObjectA__c.Name}"/>
                </apex:pageBlockSection>
                <apex:pageBlockSection title="Policy Information">
                    <apex:outputLink value="www.salesforce.com">Policy Information</apex:outputLink>
                </apex:pageBlockSection>
            </apex:pageBlock>
        </apex:sectionHeader>
    </apex:form>
</apex:page>

And override View button with it

User-added image