How to: Bypass Record Level Security in Outbound Documents

Important

This content is archived and is not being updated. For the latest documentation, see Microsoft Dynamics 365 product documentation. For the latest release plans, see Dynamics 365 and Microsoft Power Platform release plans.

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

By default, record level security (RLS) is enabled for outbound documents. It may be necessary to bypass RLS in a document when the omission of data renders the document invalid, for example, in the sales invoice document. In this case, RLS is bypassed to create a valid document. The following standard documents bypass RLS by default when sent from Microsoft Dynamics AX:

  • Sales Invoice - AxdSalesInvoice

  • Advance Ship Notice - AxdASN

  • Purchase Requisition - AxdPurchaseRequisition

It is not possible to bypass RLS for all documents at the same time. Each outbound document exchange must be manually adjusted to bypass RLS for only that document. The following steps describe how RLS is bypassed in standard documents in Microsoft Dynamics AX. Use these guidelines to bypass RLS for your own documents.

Send Electronically Method

Sending of documents can be initiated within Microsoft Dynamics AX either automatically or manually. A document is sent automatically when a posting occurs and AIF has been configured to send the posted information.

A document is sent manually through the Send electronically button. Typically, the Send electronically button calls the sendElectronically method on the base table. For more information about how to code a document to be sent manually, see Walkthrough: Deploying the Document Service in an Outbound Exchange.

Property Bag

A property bag is a collection of parameters that is sent by the table's sendElectronically method to AIF in the AxdSendContext Class. A property bag is passed unchanged from AIF to the Axd <Document> class that creates the outbound document.

A property bag is used for storing a series of properties that are relevant to the outbound document, such as if the document is an original or a copy. A property bag is also used to contain parameters. One of these parameters is used to determine whether RLS is bypassed; other parameters contain additional information that is pertinent at the time the document is sent.

The property that controls whether to bypass RLS is packed into a property bag, sent with the document, and then sent to the Axd <Document> class. The contents of the property bag are then unpacked and processed by the document class in the unpackPropertyBag method. For more information about security in Axd <Document> classes, see Security in Axd<Document> and Ax<Table> Classes.

Bypass RLS for Outbound Documents

The following procedures explain how RLS is bypassed in the standard documents. Use these procedures to bypass RLS in your own documents.

Bypass RLS in an Electronic Document

  1. In the AOT, navigate to the table associated with the document and open the sendElectronically method.

  2. Change the line of code axdSendContext.parmSecurity(true) to axdSendContext.parmSecurity(false). This directs AIF not to use RLS for the document.

  3. Save and compile the method.

The following table displays the tables that contain the sendElectronically method for the standard documents that bypass RLS.

Document

Class

Table

Advance Ship Notice

AxdASN

CustPackingSlipJour

Purchase Requisition

AxdPurchaseRequisition

VendPurchOrderJour

Sales Invoice

AxdSalesInvoice

CustInvoiceJour

Use the Send Framework

The send framework is used when the recipient of a document cannot be determined from the context of the document. As a result, the sendElectronically method is neither created nor used on the main table that is associated with the document query.

When the send framework is used, the sendDocument or sendMultipleDocuments method is called from the Main method on the AxdSend <Document> class. The RLS settings must be edited in the Main method. The AxdSendContext Class is passed as an argument to the sendDocument or sendMultipleDocuments methods.

Some documents that use the send framework require the AxdSendContext Class to bypass RLS while others do not. The following table shows outbound documents that utilize the send framework.

Document

Document class

AxdSendContext Class is called

Price List

AxdSendPriceList

Yes

Chart of Accounts

AxdSendChartofAccounts

No

Dimensions

AxdSendDimension

No

Exchange Rates

AxdSendExchangeRates

No

Bypass RLS When AxdSendContext is Called

Use the following steps to bypass RLS if the send framework is already called with the AxdSendContext class or a class derived from it.

To bypass RLS when AxdSendContext is called

  1. Open the Main method in the relevant AxdSend<Document> class.

  2. Add the line of code AxdSendContext.parmSecurity(false); before calling the sendDocument method or the sendMultipleDocuments method.

  3. Save and compile the method.

Bypass RLS When AxdSendContext is Not Called

Use the following steps to bypass RLS if the send framework is called without the AxdSendContext class or a class derived from it.

To bypass RLS when AxdSendContext is not called

  1. Open the Main method in the relevant AxdSend <Document> class.

  2. Create an AxdSendContext object in the AxdSend <Document> class.

  3. Add the line of code AxdSendContext.parmSecurity(false); before calling the sendDocument method or the sendMultipleDocuments method.

  4. Add the axdSendContext class as the last parameter to the sendDocument method or the sendMultipleDocuments method.

  5. Save and compile the method.

Example from AxdSendExchangeRates.Main

The following code shows you how to bypass RLS in the AxdSendExchangeRates class.

Static public void main (Args args)

{

AxdSendExchangeRates axdSendExchangeRates ;

AifConstraintList aifConstraintList;

AifConstraint aifConstraint;

;

axdSendExchangeRates = new AxdSendExchangeRates();

aifConstraintList = new AifConstraintList();

aifConstraint = new AifConstraint();

// The AxdSendContext object is created.

axdSendContext axdSendContext = new AxdSendContext() ;

aifConstraint.parmType(AifConstraintType::NoConstraint);

aifConstraintList.addConstraint(aifConstraint);

axdSendExchangeRates.parmShowDocPurpose(true) ;

axdSendExchangeRates.parmShowQuery(true);

// Call to axdSendContext class to bypass RLS

// before calling the sendMultipleDocuments method.

axdSendContext.parmSecurity(false);

axdSendExchangeRates.sendMultipleDocuments(

classnum axdExchangeRates),

AifSendMode::Async, aifConstraintList, axdSendContext);

}

See also

Record Level Security and Outbound Documents

AxdSendContext Class