We are trying to get the current record ID value in custom URL field of that particular record. We tried this in formula field and its works fine but when tried this in a custom URL field it's not working.

Formula field:

HYPERLINK("https://c.cs14.visual.force.com/apex/Task_Manager_Report?id="& Id, 
"Click to Open TaskManager")
  • You can't use merge fields in non-formula fields. Perhaps you should try to explain what you're trying to do?
    – sfdcfox
    Jan 29 '14 at 7:15

If you need the field as URL to be a "link" I think that you only could set the value using a trigger or workflow.


  1. Set Evaluate the rule when a record is created
  2. Add a field update task
  3. use your previous formula
  4. activate it

Trigger sample:

trigger AccountTrigger on Account ( after insert) {
    for(Account a : Trigger.new){
      a.urlField__c = 'http://.....blahblah...'+ a.Id;
  • This did not work for me. The trigger that you used here returns a 'System.FinalException: Record is read-only' error
    – jan
    Jan 31 '14 at 14:58
  • @jan see salesforce.stackexchange.com/questions/23922/…. Unfortunately if you're going to do this in a Trigger you have to take some care. If you want the field updated on all new records, this modification can't be done in a Before Insert trigger because the Id does not exist then. But records are read-only in an After Insert trigger. So the trick is to get the IDs of the records in the After Insert trigger, and make a new SOQL query and DML statement to update the records from inside the After Insert trigger.
    – abd3721
    Oct 2 '16 at 20:12

Try this. It should work

HYPERLINK('https://c.cs14.visual.force.com/apex/Task_Manager_Report?id='+Id , 'Click to Open TaskManager')


Try to use a Formula Field (with Text return) instead a URL field so that you can use HYPERLINK function in following way:

HYPERLINK("your_URL" & CASESAFEID(Id), "Text_to_view")

change HYPERLINK to url.and try it again. I think this will help to capture record id
BrowserURL=BrowserURL.right(15);//Pull from right the 15 digit Id

  • Thanks for the reply. Can you please explain me more on this. We don't want to use formula field need to use only custom URL field. Jan 29 '14 at 7:13
  • When giving an answer, some more explanation may be usefull. For instance explain why URL() works differently or some references to documentation can improve the quality of your answer. Jan 29 '14 at 7:43
  • see the edited reply
    – Sindoora
    Jan 29 '14 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.