How to combine text + auto number for record name - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Jerry YuJerry Yu 

How to combine text + auto number for record name

I have a custom object called Programs.

Under each specific Program, there is a detail related list called Program Years. When creating the record under Program Years, users are required to input the Program Year name, start date, and end date.

How do I automatically change the name of the record to Program Year name (start year - end year).

For example: 
Record name: Test Foundation
Start Date: September 16th, 2020
End Date: September 16th, 2021

After saving the record name would be Test Foundation (2020-2021)



User-added image

Best Answer chosen by Jerry Yu
Benjamin BratcherBenjamin Bratcher
Jerry, you have to use automation (process builder, flow, trigger) to update the standard name field with whatever values you want to add. That is likely how the person did it in your screenshot. You can create a formula like you did for your formula field, but reference it in automation instead and populate it that way.

All Answers

ASIF ALIASIF ALI
You need to create Process Builder for it, 
Or Before Trigger to update Name
Jerry YuJerry Yu
User-added image

For example, this record was created by typing in Custodial/Maintenance but the date - # requested # filled was added after the record was created. How do I do this?
Naveen DhanarajNaveen Dhanaraj
How about creating Formula Field? If start and Enddate value doesn.t change
Name+ YEAR(StartDate__c) + '-' + YEAR(EndDate__c)
If date field value gets changed then you will have to use Process Builder to update field.
 
ASIF ALIASIF ALI
I think It's a formula field, 
Go to object manager, choose this object and this field, And get formula logic from this field.
Jerry YuJerry Yu
Hi Naveen, how would I make that the name and indexed field?
Naveen DhanarajNaveen Dhanaraj
Create formula field and Use Insert field option and Create formula as above formula.
Jerry YuJerry Yu
Hi Naveen,

So I just tried what you suggested and used the TEXT formula return type, and it won't let me add the start year and end year since that's a number.
Jerry YuJerry Yu
Oh wait, this works

Name + TEXT(YEAR(Start_Date__c)) + '-' + TEXT(YEAR(End_Date__c))
ASIF ALIASIF ALI
Use TEXT(Start year) and TEXT(End year)
Jerry YuJerry Yu
I've created the field but I want to make that the NAME field
User-added image
Jerry YuJerry Yu
User-added image

How do I make the Program Year Name the primary name field? 

I've posted a picture above with the custodial/maintenance example.
Jerry YuJerry Yu
User-added image

How do you think this person did it? 
Naveen DhanarajNaveen Dhanaraj
By Updating Name field via process Builder or Trigger..
Benjamin BratcherBenjamin Bratcher
Jerry, you have to use automation (process builder, flow, trigger) to update the standard name field with whatever values you want to add. That is likely how the person did it in your screenshot. You can create a formula like you did for your formula field, but reference it in automation instead and populate it that way.
This was selected as the best answer