0

I want to populate the name of a record by concatenating the values of two other fields, is this possible? I attempted this by using a before insert trigger, but since the system validations(checking if required fields are filled) comes before the before triggers are executed - this didn't work.

Any ideas guys?

8
  • Try it by using workflow rule - field update
    – Peeyush
    Feb 9 '16 at 5:37
  • Have you marked the name field as required on layout or at the field definition level ? If yes it will fail with workflow as well. Feb 9 '16 at 5:39
  • @Peeyush Workflow field updates too occur later in the order of execution. The system validation rules fire first and put the DML to a halt before it reaches the workflow rule part. Thanks
    – Prajith
    Feb 9 '16 at 5:39
  • @Salesforcesmarty This is the standard name field we are talking about, this is required at all levels.
    – Prajith
    Feb 9 '16 at 5:40
  • But you must enter some test value in name field, and then replace it by W/F on creation.
    – Peeyush
    Feb 9 '16 at 5:42
0

Problem is you want to pre-populate fill Name so it doesn't throw any validation error. Workaround is as:

  1. Create a Visualforce page similar to this

    <apex:page standardController="Salesforce_Object__c " action="/{!sobjectKeyPrefix}/e?name={!Name_You_Want_To_Pre-populate}&nooverride=1">
    </apex:page>
    
  2. Replace Salesforce_Object__c with your object and {!Name_You_Want_To_Pre-populate} with the value you want to be pre-filled.

  3. Override the New button with the above page.

Customer will not need to enter the name field always.

  1. Setup workflow or trigger to replace with actual values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.