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

insert record and workflow-trigger

I'm creating a new record in a custom controller of a visualforce page.This getting the field values from a visual force page where the user insert only the values of 3 fields.

After pressing the button save i open the new record in edit mode and the user can insert the values of other 7 fields for the same records.



My question is about:

insert record;


 this instruction in the custom controller runs the triggers and workflow rules of the object?


I have an insert when the user press the save button on the first page (3 fields), i think that i will have problems because on first save i haven't all the fields populated.

Thanks in advantage for any advice.



Well good question!

Lets understand the flow!


Whenever you make a insert call

What actually happens is


Insert >> Validations (Required Fields/System Validation/Page alyout sepecific validation) >> Before Trigger >> After Trigger >> Workflows


So in a nushell the workflow and field will fire. But insteading of depending on a worklow you can set the field values from your page as well.


Now say in step 1 you are entering 3 fields and doing insert. Well the thumb rule is you have to fill out all the required fields to make the insert successfull. So if there are no such required fields other than those 3 that you are letting the user to enter it wont be an issue. Keep in mind if user is not entering value for a required field you can always set the value from your controller before making the insert call


You can go through this link. This basically tells you about the execution order


When you insert a record, all required fields must be populated. Here I don't mean fields that are marked "required" in the layout or VF page, but fields that you marked as "required" when you created the custom object.


So, if all 7 fields in the edit page are nillable (not required) you will not have probelms on insert.


Apex Editor LS - free alternative to apex editor.