You need to sign in to do that
Don't have an account?
Object record Name as formula
I have a custom object named Consultant that holds contact information for consultants of our company. FirstName and LastName are the two fields within this custom object that represent the consultants name. My issue, is that when running a lookup to this Consultant object, the record name is the value that comes up. I can add fields to the lookup so you could see the FirstName and LastName but there is still a problem. The object that is related to Consultant, will only show the record name in the lookup field in the record. I want to make my record name for Consultant a formula field that is a concatenation of First Name and LastName. The standard object Contact has a setup like this and I want to replicate it. I don't see how to handle this if it's even possible. Can this be done and if so, how?
Thanks,
Ralph
The record name cannot be a formula or have a default value. When you set up the Object, did you select the record name as a text or auto number?
This workaround will not work if it's an auto-number:
Create a Formula field on the Consultant object with the formula: First_Name__c &" "& Last_Name__c call it "Concatenated Name", for example.
Create a workflow rule to update the record name: for the Rule Criteria, enter Name != Concatenated_Name__c for Evaluation Criteria, set it to Every time a record is created or edited.
For the field update, set Field to Update: Consultant Name and use the Formula Value: Concatenated_Name__c
With this workflow in place, you could enter any information into the record name to get around the field requirement, and workflow will update it accordingly. Seems silly, but it just may work.
All Answers
The record name cannot be a formula or have a default value. When you set up the Object, did you select the record name as a text or auto number?
This workaround will not work if it's an auto-number:
Create a Formula field on the Consultant object with the formula: First_Name__c &" "& Last_Name__c call it "Concatenated Name", for example.
Create a workflow rule to update the record name: for the Rule Criteria, enter Name != Concatenated_Name__c for Evaluation Criteria, set it to Every time a record is created or edited.
For the field update, set Field to Update: Consultant Name and use the Formula Value: Concatenated_Name__c
With this workflow in place, you could enter any information into the record name to get around the field requirement, and workflow will update it accordingly. Seems silly, but it just may work.
Your solution for the above post was brilliant, but if the record hasn't been manually edited the workflow rule never gets triggered so you end up with some records displaying the concatenated version and some not. I'm hoping you also have a solution to this problem.
Thanks for your help with our problems.
dgb511
dave@reln.com
Here's where the Excel Connector comes in handy...
As you've noticed, workflow is not retro-active, so any records created/edited prior to the workflow will not display the concatenated version.
Using the Excel Connector, select your object and query all the records with a Created Date less than the date workflow was activated (the Record ID, Record Name, and Concatenated Name fields will suffice).
Select the Record Name cells on the worksheet and Update Selected Cells from the excel connector menu.
It may take a few minutes depending on the number of records you have, but it's a lot easier than editing each individual record to trigger workflow!
Note: To verify that the update was successful, refresh the query by selecting Query Table Data after you run the update.
Thanks, and you're right it's a lot easier than manual editing hundreds of records.
Frustrating ...
i tried seeting default value using W.F Rule... FAILED
I wrote Trigger to set default value for Name field (as same as your trigger.. given above)..... FIALED
can any1 help me on this... any idea..?
Has anyone found an efficient solution to this?
CaptainObvious' post above inspired this. Because the Flow builder is relatively new, and I had to write this out for our IT Knowledge base anyway, I figured I'd share it here in case it helps someone.
This does still require anything to be typed into the field to save a record, but...
I got this to work for me today using the a Flow. I set the Name field on my object to a text(80) field type. I stopped trying to make it auto-apply the naming convention I wanted upon creation of the record and instead used a Flow to automatically update the name upon Create (and Update, but that's optional)
I wanted the record name to populate the values from the Contact and Date fields.
In Setup > Home > Process Automation > Flows - click New Flow.
Then select " Record-Triggered Flow"
I selected the object I was working on, in this case a Trespass Tracker.
Optimize the flow for: "Actions and Related Records
Click Done then press the + sign under "Run Immediately"
Scroll downa dn select Update Records.
Name it as you see fit...
Choose the field: Name
In Value, you can't select multiple things at once to add them together all at once. You need to find the field you want to reference, copy and paste it into a document, X out that option and then select the other field you are wanting to add, and repeat this as many times as you see fit.
For example, I clicked Value, then $Record then Contact__r then found Full Name which looks like this: {!$Record.Contact__r.Full_Name__c}
I copied that and then X'ed it out. I then did $Record again and clicked $Date_of_Trespass__c which gave me: {!$Record.Date_of_Trespass__c}
In a word doc, I put {!$Record.Contact__r.Full_Name__c} - {!$Record.Date_of_Trespass__c} together and copied and pasted that whole thing into the Value field. (Yes it let me add the spaces and the - in between)
Now my records all say "John Doe - April 5, 2022" for example.
I chose to have this Flow trigger when a record is created OR updated. I exported all existing records and then ran an update through Data Loader with a 1 (anything different than it was will work) in the Name field. Doing so applied the new naming convention to all past records as well.
I hope this is helpful to someone!
I hit the same hurdle and now having to recreate the object all over with a new auto-numbered name field and a separate field for the actual name I wanted. Not sure if it will solve entirely as I would have to manually insert my new field in all page layouts etc