+ Start a Discussion
AncaDAncaD 

Assign URL to a field

I have a custom object and want to add its ID field to a related list of another object. I do this in apex code (I can't make it a lookup field). What I need also is to make the ID field a hyperlink to take the user to the tab of the object to which is part of.

 

 

Can anybody, please, tell me how to do this?

 

 

Thank you for your help. 

CaptainObviousCaptainObvious

 

Not sure if this will help, but try this:

 

Create a new formula field on your custom object, call it Details
For the formula, use HYPERLINK(Id,'View','_self')

 

Now go to the other object, edit the layout and add the Details field to the related list. You'll be able to click the View link to navigate to the related record.

 

If you want to display the Id instead, change the formula to HYPERLINK(Id,Id,'_self')

AncaDAncaD

Thanks for your answer, CaptainObvious.

 

That actually didn't work for me - it gives me an error of 'URL no longer exists'.

 

this is how the formula for the newly created field (which I display) looks like:

 

HYPERLINK(Score__c, Score__c, '_self')

 

where the first Score__c is the custom object where I want to go, the second Score__c is the field that I have on the current page (which is of a different object than the one I want to go to). The second Score__c is a text field which I populate in an apex class with the ID from the Score__c object.

 

I'm thinking that probably it would be easier to do it in the apex code, but I don't know how to assign the URL to the field.

 

Do you have any experience with that?

 

 

Thanks again

mpannmpann

Anca,

 

i would agree with CaptainObvious, that if the records are directly related, then it would be much simpler to use a formula field. If your Score__c object is the parent of the object "Child__c", then you would create a formula field on the child object that looks like this:

 

Formula (text)

 

HYPERLINK("/"&Score__r.Id,Score__r.Name, "_self")

 The formula assumes that the lookup field to your Score__c object is also called Score__c!


 

 

This acts like any other field on the object and can be included in page layouts, related lists or tab views.

Message Edited by mpann on 09-04-2009 01:28 PM