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
mh1974mh1974 

Apex Trigger on a custom object using a Visualforce page

I have created a custom object that is updated through a standard tab.  I have created a trigger that fires when the object is updated and creates and writes to a second custom object.  So far so good,  works without a hitch.

 

The problem:  I don't want to use the standard layout,  so,  I have created a Visualforce page to do the job - it uses the object as the standard controller.  When I change the data and hit the save button,  the update is succesfull,  but,  the trigger does not fire and the second object is not created.

 

Does anyone have any idea why the use of a Visualforce page should make a difference to the firing of a trigger?.

Best Answer chosen by Admin (Salesforce Developers) 
mh1974mh1974

I have solved the problem.  I created a contoller class, added a save method to it and used it as an extension to my Visualforce page.

 

This trigger now fires....go figure!

All Answers

aalbertaalbert

Triggers resides in the data layer so you should be able to use the Visualforce page with a standard controller to save the initial record and initiate the trigger.

 

Can you post the trigger code? Any chance there is logic in the trigger that is not being met when creating the record in the Visualforce page vs the standard page layout?

 

 

 

mh1974mh1974

I have solved the problem.  I created a contoller class, added a save method to it and used it as an extension to my Visualforce page.

 

This trigger now fires....go figure!

This was selected as the best answer