10

I have created a new custom object for which I have no use for a record name. Is there any way which I am able to remove name from the list of standard fields?

If I am required to name the object, I would prefer it that this name be created automatically based on values populated from other fields, not simply an auto-number or text?

Is there some kind of work-around for this?

1
  • 3
    What we really need is Salesforce to allow overwriting an auto-numbered Name with a String! :-) Commented May 16, 2014 at 15:02

3 Answers 3

14

You can do this without throwing away the native page layouts. Assuming your object is Person__c:

  1. Override the New button with a redirector like this to set a sensible default value:

    <apex:page
        standardController="Person__c"
        action="{!URLFOR($Action.Person__c.New, null, ['Name'='Derp'], true)}"
    />
    
  2. Create a Workflow Rule that sets the actual intended value (eg from other fields)

    workflow-details

This displays a non-empty Name that is overwritten by a workflow rule when saved. It's currently the only way to keep the native page layouts while not requiring the user to enter a non-empty Name.

Note you can default the Name using Predefined Field Values on a Create Record Publisher Action.

As you noted, you can remove the Name from Page Layout only if it is an auto-number field.

5
  • When are you setting the workflow rule to run, though? When a new record is created or updated?
    – toolshed
    Commented May 16, 2014 at 15:45
  • "Evaluate the rule when a record is created, and every time it’s edited." @Addikt Commented May 16, 2014 at 15:58
  • This is the pattern we've used for years, and it works great. (You can even go the extra mile and use the "$Action.Person__c.New" technique in URLFOR). The problem is that this whole pattern fails badly inside of the Salesforce1 mobile app. We're still experimenting with the best solution for this problem.
    – Matt Welch
    Commented May 17, 2014 at 16:53
  • 2
    @user320 Sorry. Was away for most of the weekend. URLFOR has a fourth parameter which, when set to true, will skip the override, and take you straight to the "new" page for the object.
    – Matt Welch
    Commented May 19, 2014 at 16:05
  • 1
    Very forthcoming addition @MattWelch - thanks! I've tested this works OK and incorporated it :-) Commented May 19, 2014 at 16:11
3

This is a great example of when to use Flow. Just create a Flow to gather all the data from which the name can be constructed. The Flow will create the record. You will need give users a link or tab to run the Flow. You probably want to override the "new" button for that object to run the Flow instead. Very little code required, easy to maintain!

1
  • 1
    Nice angle on flow, love this! Commented Oct 20, 2014 at 11:39
2

"Is it possible to create a SF object without a name" - No each sObject have to have value in this field

"or automatically populate it based on other field values?" - It is possible only by Visual force page. You just need to override standard save method and set name using apex logic.

3
  • Yes, it's possible to insert a custom SObject record without a name. The Name defaults to its Record ID. Try it in Apex. Commented Oct 23, 2019 at 19:48
  • And there are other ways to populate the Name field upon DML such as Triggers, Workflow, Process Builder. And then one can also create records with auto-populated Name via Quick Actions and Flows and Lightning Components + Visualforce Commented Oct 23, 2019 at 19:50
  • 1
    Hi @ScottPelak I am full of respect that you find time to comment 5 year old answer :) Since you did it, I feel obliged to address your comments ;) I am not even sure how it worked back then, but I think it was only way to remove Name field from layout for user. You are right you can not populate this field in backend and it will be populated in backend. but still you would have to set meaningful name with apex/workflow etc. Commented Oct 24, 2019 at 9:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .