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
Felix Jong Seok ChaeFelix Jong Seok Chae 

Can URL-typed field have more than one url?

I am developing this in SFDC.
I have a custom field whose type is URL.
I noticed that if I do the following, I can set the url of the case record.
myCase.customField = 'xxx.salesforce.com/recordid_of_othercase/d'
I would like to create 5 links of 5 different recordids in this custom field instead of having just one link for one recordid.
Q1. Can I do this in one custom field in some way or should I create 5 custom fields and fill each field with recordid?
Q2. I heard that I can change the way the url looks, having caseNumber field instead of a long url. What is the exact format of the code for this?
Thank you.
Best Answer chosen by Felix Jong Seok Chae
HARSHIL U PARIKHHARSHIL U PARIKH
Hi Felix,

All_Associated_Cases_URL__c is not URL data type anymore. It's Long Text data type with about 5 to 6 lines visiable to see.

in addition, whichever field you are storing Ids or links etc. would need to be a long text data type field because  that's the only one which allows you to go above that 255 ch limit.
 
EveryParentCase.All_Associated_Cases_URL__c += 'https://na40.salesforce.com/' + str + '\n';

Above code will make all the associated cases URLs to line up one after another since it contains += and '\n' functions.

the image I have posted in above post is the final output you would receive.

You are going to have to use the whole URL and you can not just use the Case Numbers alone.
Lets say you are able to line up all the case numbers one by one in that Long Text field, how would they have link behind them. This happens only in reporting. Our Full URL field is a link itself which open up a child case in new window once you click it.

hope it helps!

All Answers

Raj VakatiRaj Vakati

Hi Felix,
Please find my comments here
Q1. You can have any number of URL in one URL custom Filed ( Max Length is 255 )
Q2 . How you wanted to store the value and retrieve it again is the key consideration. lets suppose you store the complete URL in first and from second you can store only case number  ( write custom logic to do it ) 

Thanks ,

Raj

HARSHIL U PARIKHHARSHIL U PARIKH
Hello Felix Jong,

I see what you are asking. Yes, it is possible with the Apex Trigger. I have thought about it via Process Builder but it is not possible in my opinion.

This is the behavior or output would the following trigger provides,

User-added image

Object: Case
Fields: All_Associated_Cases_URL__c 

Trigger Code:
 
Trigger AggregatingLinks On Case(After Insert, After Update, After Delete, After UnDelete){

    List<Case> ParentCaseListToUpdate = New List<Case>();
    
    List<Id> ParentCaseId = New List<Id>();
    
    If(Trigger.IsInsert || Trigger.IsUpdate || Trigger.IsUnDelete)
    {
        For(Case ChildCase : Trigger.New)
        {
            
            If(childCase.ParentId != null)
            {
                ParentCaseId.add(childCase.ParentId);
                AggregateResult[] aggregate = [Select Id FROM Case WHERE ParentId =: ChildCase.ParentId
                                                                                GROUP BY Id];
                
                List<Id> allChildCaseIds = New List<Id>();
                
                If(aggregate.size() > 0){
                    For(AggregateResult EveryAR : aggregate)
                    {
                        allChildCaseIds.add(EveryAR.Id);
                    }
                }
                
                For(Case EveryParentCase : [Select Id, All_Associated_Cases_URL__c FROM Case WHERE Id =:ParentCaseId])
                {
                    EveryParentCase.All_Associated_Cases_URL__c = '';
                    For(String str : allChildCaseIds )
                    {
                        EveryParentCase.All_Associated_Cases_URL__c += 'https://na40.salesforce.com/' + str + '\n';
                    }
                    ParentCaseListToUpdate.add(EveryParentCase );
                }
              
            }
        }
    }
    Try{
        If(!ParentCaseListToUpdate.IsEmpty()){
            update ParentCaseListToUpdate;
        }
    }
    Catch(Exception e){
        System.debug('Theown Exception for AggregatingLinks Trigger Is: ' + e.getmessage());
    }
}

Hope this helps and if it solves the query then please mark it as BEST ANSWER since it will help other users in community as well!
Thank You Sir!
Felix Jong Seok ChaeFelix Jong Seok Chae
Thank you for your help always. 
Btw the code EveryParentCase.All_Associated_Cases_URL__c += 'https://na40.salesforce.com/' + str + '\n';
doesn't look like it works because they concatenate strings in one line instead of having several lines.\
Could you look into this?
Felix Jong Seok ChaeFelix Jong Seok Chae
Also, in the all_associated_cases_url__c, how can i use a casenumber for that url instead of having a whole url appeared?
Glyn Anderson 3Glyn Anderson 3
I suggest that you don't hard code the instance in the URL (i.e. "https://na40.salesforce.com/").  Instances can change, and sandboxes are on different instances than production - your full sandbox links will link to production rather than to the records in the sandbox.  Instead, just use a relative URL (i.e. "/").  This will ensure that the link links to a record in the same org.

URL fields can't display arbitrary text link an HTML <a> tag can.  But you could do this with a formula field that uses the HYPERLINK function.  If you put the case ids and case numbers into separate (hidden) text fields, you could create a single formula field that displays five different HYPERLINKs, each one using a different case number and URL.  See this reference: https://help.salesforce.com/articleView?id=customize_functions_a_h.htm&language=en_US&type=0  and search for "HYPERLINK".
HARSHIL U PARIKHHARSHIL U PARIKH
Hi Felix,

All_Associated_Cases_URL__c is not URL data type anymore. It's Long Text data type with about 5 to 6 lines visiable to see.

in addition, whichever field you are storing Ids or links etc. would need to be a long text data type field because  that's the only one which allows you to go above that 255 ch limit.
 
EveryParentCase.All_Associated_Cases_URL__c += 'https://na40.salesforce.com/' + str + '\n';

Above code will make all the associated cases URLs to line up one after another since it contains += and '\n' functions.

the image I have posted in above post is the final output you would receive.

You are going to have to use the whole URL and you can not just use the Case Numbers alone.
Lets say you are able to line up all the case numbers one by one in that Long Text field, how would they have link behind them. This happens only in reporting. Our Full URL field is a link itself which open up a child case in new window once you click it.

hope it helps!
This was selected as the best answer
venkata kalyani konakallavenkata kalyani konakalla
Can i add up to 100 URL'S in a single URL data type field?
KushiKushi
I'm having a similar issue. I m trying to update a field with multiple urls. I tried to line break with '\n' but its just concatenating and its treating both the urls as one. 
sindhu challabotla 8sindhu challabotla 8
Hi, 
I want to have 2 or more url's in a single field. Can this be possible with in fields or do I need to do something else?
Thanks Sindhu