You need to sign in to do that
Don't have an account?

Populate an empty required field before validation rules
Hey all,
Here's my problem :
In my Custom Object Customer__c, I would like to populate my Record Name with 2 others fields. This works fine with a Trigger, but only with updates. When I try to create a new record, it tells me that the Record Name is a required fields. I guess that validation rules come before trigger actions.
Does anyone can explain me how to make it ?
Thx a lot,
Regards.
Maybe i'm doing wrong ?
Message Edited by yao on 09-18-2008 08:06 AM
Gotcha. I made the assumption that you'd have the user still enter an initial value for that required field, but I see that's not what you want. In that case, you could write either a small s-control or VisualForce page that assigns a static (initial) value to that required field as new records are created. There must be a cleanner and more elegant way to achieve what you're trying to do, but I'm not aware of :)
This is how I would do it: I'd have either an s-control or VisualForce page that overwrittes the standard "New" button for your custom object, and in that code, assign an initial value to your "Name" required field. Then simply use your Apex trigger to change that required field to the values that were assigned to the First and Last Name fields within that record (you already have this built). If you decide that you want to go this route, here's a snippet of what the s-control would look like:
Again, since you're extending the standard New button functionality of your object, you'll need to overwritte it and then associate it with this s-control. All the above code does is to assign the value of the field variable named tsk5 to "This will auto-populate". You want to change tsk5 to whatever variable name is mapped to your required field for the Name. When the user clicks on the New button to create a new Customer record, they should see that static string auto-populated to your required field. Then they would enter the first and last names, and once the record is saved, your trigger should fire and change the Name field to First + Last Name.
Message Edited by HL-Dev on 09-19-2008 02:29 PM
Message Edited by yao on 09-22-2008 04:29 AM