Question
David Satorres · Jul 20

Suppress triggers in object approach, like %NOTRIGGER for sql

Hi,

When for any particular reason I need to update a record and don't want to pull the triggers, the keyword %NOTRIGGER can be used. But I've been trying to do the same when I change the row using the object approach, but I can't find it. Anyone knows if it's possible to avoid pulling triggers when working with objects?

Sadly, the utility "DISABLE^%NOTRIGGER" doesn't seem to exist ;-)

Thank you,
David

Product version: IRIS 2020.1
10
1 0 2 81
Log in or sign up to continue

I had a similar problem on an old project.
Data could be entered as an object such as SQL.
In both cases there were exceptions for processing the business rules contained in the triggers. The most common was loading data imported from an external source where some mandatory values were missing. And normally this charge was done along with the normal functioning of the application.
To get around this we created control flags to be able to process this data.

Something like that:
Set ^Flag = $JOB_"|"_"Action:IgnoreBusinessRules"

On the %Library.Persistent extend class:
Class User.Sample Extends %Persistent
{

Method %OnBeforeSave(insert As %Boolean) As %Status [ Private, ServerOnly = 1 ]
{
    /// Abort business rules
    If $Get(^Flag)'="" & ($Piece($Get(^Flag),"|",1)=$JOB) & ($Piece($Get(^Flag),":",2)="IgnoreBusinessRules")  Quit $$$OK
    /// Before this point, follow normal business rules.
    Quit $$$OK
}

Trigger TrgBefInsert [ Event = INSERT, Time = AFTER ]
{
    /// Abort business rules
    If $Get(^Flag)'="" & ($Piece($Get(^Flag),"|",1)=$JOB) & ($Piece($Get(^Flag),":",2)="IgnoreBusinessRules")  Quit $$$OK
    /// Before this point, follow normal business rules.
    Quit $$$OK
}

Trigger TrgBefUpdate [ Event = UPDATE, Time = AFTER ]
{
    /// Abort business rules
    If $Get(^Flag)'="" & ($Piece($Get(^Flag),"|",1)=$JOB) & ($Piece($Get(^Flag),":",2)="IgnoreBusinessRules")  Quit $$$OK
    /// Before this point, follow normal business rules.
    Quit $$$OK
}

}

Hi Marcio!

You did a hell of a job here! :-) But I was looking for a specific in-build solution.