Unchecked keyword in Dynamics AX [unchecked(Uncheck::TableSecurityPermission)] using X++

Unchecked reserve word should be used explicity if we want to override the table security setting permissions and execute the DML operations still.

Below are some examples:

Example 1:

// turn off security so records can always be created
unchecked(Uncheck::TableSecurityPermission)
{
        ledgerTrans.insert();
}


Example 2:

// allow any user with access to class to delete by turning security permissions off
unchecked(Uncheck::TableSecurityPermission)
{
delete_from ledgerTrans
where ledgerTrans.TransDate == periodNext &&
ledgerTrans.PeriodCode == PeriodCode::Opening;

delete_from ledgerBalances
where ledgerBalances.TransDate == periodNext &&
ledgerBalances.PeriodCode == PeriodCode::Opening;

delete_from ledgerBalancesDim
where ledgerBalancesDim.TransDate == periodNext &&
ledgerBalancesDim.PeriodCode == PeriodCode::Opening;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: