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
MrSalesForceMrSalesForce 

Allow Apex code to ignore validation rules

Is it possible to allow an apex trigger to write to an object without getting stuck in validation rules? 

We have an object where it should be possible to change it via code but not via the user interface (read only does not work since only some types of the object cannot be changed).

 

It would be nice if it was possible to see if a change has been made by the system or by a user using the GUI.

 

Any ideas on how to accomplish this?

 

BR
Mattias

bob_buzzardbob_buzzard

I wrote a blog post on this very subject presenting one solution:

 

http://bobbuzzard.blogspot.co.uk/2011/11/bypass-validation-rules-from-apex.html

MagulanDuraipandianMagulanDuraipandian

Make use of immeditate attribute.

 

Example:

 

<apex:inputputField value="{!var}" immediate="true"/>

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

 

SFDC Blog

 

If this post is your solution, kindly mark this as the solution.

bob_buzzardbob_buzzard

That also ignores anything the user may have input on the page.