Archive

Archive for November, 2010

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

Publish Selected Fields using AIF without Send Framework

November 9, 2010 1 comment

Sample example is written for publishing selected field based on AIF setup made in Data-policies form without using AxdSend framework class.

/// <summary>
///    The <c>LedgerTableRead</c> job will published the xML to the folder
///    mentioned in channel path.
///    Note: Once the job is executed sucessfully please run the AIF job 
///    to push the xML outside.
/// </summary>
public void LedgerTableRead()
{
    AifEntityKey        entityKey         = new AifEntityKey();
    AifConstraint       aifConstraint     = new AifConstraint() ;

    AifSendMode         aifSendMode       = AifSendMode::Async;

    AifEntityKeyList    entityKeyList     = new AifEntityKeyList();
    AifConstraintList   aifConstraintList = new AifConstraintList();

    LedgerTable         ledgerTable;
    ;

    select firstonly ledgerTable
        where !(ledgerTable.AccountPlType like LedgerAccountType::sum);
    {
        entityKeyList.addEntityKey(entityKey);
        entityKey.parmTableId(ledgerTable.TableId);
        entityKey.parmRecId(ledgerTable.RecId);
        entityKey.parmKeyDataMap(SysDictTable::getKeyData(LedgerTable));

        aifConstraint.parmType(AifConstraintType::Customer);
        aifConstraint.parmId(LedgerTable.AccountNum);
        aifConstraintList.addConstraint(aifConstraint);

        /* This will populate the xML based on the AIF setting for COA */
        AifSendService::submitDefault(classnum(LedgerChartOfAccountsService),
                                      entityKey,
                                      aifConstraintList,
                                      aifSendMode);
    }
}

Once the above job is executed, the record with get inserted into Queue Manager. Please execute the following AIF job to push the data outside.

public void Run_AIF_Job()
{
    ;

    new AifOutboundProcessingService().run();
    new AifGatewaySendService().run();
}

hAppies DAX 🙂

Categories: X++ stuffs
%d bloggers like this: