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
chriscwharrischriscwharris 

Using Workflow to set NAME

I have built an app with a number of objects in a hierarchy. I had figured using an auto number for the NAME field would be useful for quite a few of the objects however now I'm adding data for testing I realise that the NAME field isn't very helpful in lookups and the recent items list. So I've decided that making the TEXT may be a better idea. This leads to another issue in that duplication of data entry will be required as in certain circumstances the NAME would make sense as a computation of a number of existing text fields on the object.
I have seen posts about using workflow to set the NAME field when saved instead. Anyone else use this approach? It's a real pity that the NAME field can't have a formula!
NagendraNagendra (Salesforce Developers) 
Hi chriscwharris,

One way to do this is to use a quick action. You can use predefined values to set the value of the Name field, and if you use an object-specific quick action to create the record as a child of another record, you can even include field values from the parent record. Additionally, you can remove the Name field from the quick action form even though it's a required field -- as long as you provide something in the predefined value for that field, the record will save.

For example: say you're creating an opportunity from an account, and you always want the opportunity name to be in the format "AccountName - Date Created". You would:
  • From the Account object, create a new Action of the Create a Record action type, with Opportunity as the target object.
  • Set up the form to include the fields you care about. Optionally, you can remove the Name field from the form. Save the form.
  • On the action detail page, in the Predefined Field Values related list, create a new predefined value for Opportunity Name. For the formula, use Account.Name & " - " & TODAY(). Save the predefined value.
Now you can add the quick action to your page.

This has some limitations in support. You can't use quick actions (at this time) on the actual related list in the page layout - they can only go in the actions sections. In Lightning this works pretty well because all the actions (standard/custom buttons & quick actions) are combined in a single list. In Classic quick actions can only placed in the Chatter publisher.

Sometimes, Organizations wants to set Name field, as the Name field is referred in Reports, Related Fields(Lookup), Lists, Search Results, Recent List etc.

By controlling this field using a workflow, we are actually setting this field with consistent data and eventually reducing the user input error.

Kindly mark this post as solved if the information helps.

Best Regards,
Nagendra.P