Home > X++ stuffs > Development Tips on Application Integration Framework

Development Tips on Application Integration Framework

Is there any way to turn off the mandatory fields when working on AIF?
All the table fields for which the mandatory field is said to “Yes” are by default enabled in AIF data-policies form.

To make this field as not mandatory on Ax Table classes.

In AxBc’s please override the method initMandatoryFieldsExemptionList () if you don’t want to set the mandatory field in xML as following.

protected void initMandatoryFieldsExemptionList()
{
    super();
    
    this.setParmMethodAsNotMandatory(methodstr(AxSalesLine,parmCust));
}

The setParmMethodAsNotMandatory () – Specifies that the field represented by a parm method shouldn’t be mandatory in the schema and the XML.

The above code will add all the mandatory fields to the exemption list.

Is there any way to set mandatory fields when working on AIF?
Yes. InitMandatoryFieldsMap () method creates a list of mandatory fields that are specific to the document. The document must override this method to add mandatory fields that are not mandatory in the data model

To enable the mandatory fields through coding: In AxD class please override the method
initMandatoryFieldsMap () if you wanted to make this fields mandatory in xML

protected void initMandatoryFieldsMap()
{
    super();
          
    this.setParmMethodAsMandatory(classnum(AxSalesLine),
                                  methodstr(AxSalesLine,parmSalesQty)) ;

Simple scenario to illustrate the use of above function is as follows:

Say if you want to import a Sales Order for which the sales quantity should not be less than 100. If it’s less than 100 then it should throw error at the time inbound operation.

Note: Sales qty is not mandatory in Sales Line table.

To make a table field as mandatory both in schema and Xml then in the initMandatoryFieldsMap () the following code should be introduced.

this.setTableFieldAsMandatory(tablenum(SalesLine),
                              fieldstr(SalesLine,SalesUnit));

Hope this piece of information is useful to AIF developers 🙂

Categories: X++ stuffs
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment