Search This Blog

Monday, February 25, 2019

Table field not populated with inbound XML document data in AIF Document Service in AX 2009



Issue: We had a requirement to send in a InventDimId as part of creating a Sales Order, but the InventDimId field was not being populated in AxInventDim table.

Solution : Change the InventDim field property :"AllowEditOnCreate" from No to Yes.



So that system can populate it while its reading the inbound XML.

May be a small thing but thought its worth sharing here.

HappyDaxing...!



Friday, October 12, 2018

Split string useing List in AX2009

static void Job277(Args _args)
{
    List _list = new List(Types::String);
    Container packedList;
    ListIterator iterator;
    str cade = "Jhon*,smt*,and*,caro*";
    ;
    _list = Global::strSplit(cade,",");
    iterator = new ListIterator(_list);
    while(iterator.more())
    {
        packedList += iterator.value();
        iterator.next();
    }
    info(conpeek(packedList,2));
    info(strfmt("%1",conlen(packedList)));
 
}


Wednesday, October 3, 2018

X++ code to Sending email using code and data with table format


static void SendEmail(Args _args)
{
    SysEmailParameters parameters = SysEmailParameters::find();
    SMTPRelayServerName relayServer;
    SMTPPortNumber portNumber;
    SMTPUserName userName;
    SMTPPassword password;
    Str subject,body;
    InteropPermission interopPermission;
    SysMailer mailer;
    System.Exception e;
    str s;
    CCHTMLString            htmlString;
    ;
    if (parameters.SMTPRelayServerName)
    relayServer = parameters.SMTPRelayServerName;
    else
    relayServer = parameters.SMTPServerIPAddress;
    portNumber = parameters.SMTPPortNumber;
    userName = parameters.SMTPUserName;
    password = SysEmailParameters::password();
    subject = "Subject line for the email";
    body = "<B>Body of the email</B>";

    CodeAccessPermission::revertAssert();

    try
    {
    interopPermission = new InteropPermission(InteropKind::ComInterop);
    interopPermission.assert();
    mailer = new SysMailer();
    mailer.SMTPRelayServer(relayServer,portNumber,userName,password, parameters.NTLM);
    //instantiate email
    mailer.fromAddress("xx@xxxxxx");

    mailer.tos().appendAddress("xxxx@xxxx");
    mailer.subject(subject);
   // mailer.htmlBody(body);
    s = '<table border="1"> <tr> <td>Sl.No  </td> <td>Item number   </td> </tr>';
     htmlstring = strfmt(s);
    
     s = '<tr> <td>%1  </td><td>%2  </td></tr>';
     htmlstring += strfmt(s,1,'test12');
      htmlstring += strfmt( '</table>');
     mailer.htmlBody(htmlstring);
    mailer.sendMail();
    CodeAccessPermission::revertAssert();
    info("Email has been send!");
    }
    catch (Exception::CLRError)

    {
    e = ClrInterop::getLastException();

    while (e)

    {
        info(e.get_Message());

        e = e.get_InnerException();
    }
    CodeAccessPermission::revertAssert();
    //info(e);
    info ("Failed to Send Email some Error occure");
    }

}


Happy Daxing..

Tuesday, March 20, 2018

AX2009 How to get Item default order settings ...

static void ItemDefaultDimensions(Args _args)
{
    InventTable                 inventTable = inventTable::find('000367');
    InventItemOrderSetupType    setupType   = InventItemOrderSetupType::Sales;
    InventDim                   inventDim;
    ;

    inventDim.InventSiteId = inventTable.inventItemOrderSetupMap(setupType).inventSiteId('2', inventTable);

    inventDim.InventLocationId  = inventTable.inventItemOrderSetupMap(setupType,InventDim::findOrCreate(inventDim).InventDimId).inventLocationId(inventDim.InventLocationId,inventTable,'2');
                                                                                                                                       
    inventDim.ConfigId = inventTable.StandardConfigId;

    inventDim = InventDim::findOrCreate(inventDim);

    info(strFmt('Dim.  %1', inventDim.inventDimId));
    info(strFmt('Site  %1', inventDim.InventSiteId));
    info(strFmt('Warehouse  %1', inventDim.InventLocationId));
}

Wednesday, November 15, 2017

AIF (Endpoint) Error : The user is not authorized to perform this action.


"The user is not authorized to perform this action." 
We started getting this error message in our AX 2009 System, when ever we try to consume an XML file using an Endpoint  thru a File System Channel to create a Sales Order.
We did not made any code changes / setup changes, but all of the sudden started getting this error.

Solutions :
1. Validate the "SourceEndpointUser". in inbound XML 
The User ID should be a valid user Id in DAX, in GNS Active Directory and the "\" should be back slash in the XML file or where you use this combination in entire process or setup. ex : Domain \ User Id.
In our case when we had the above error, the SourceEndPointUser user id was deleted from the Active Directory in GNS, so we added it back to Active Directory then it solved the problem.
NOTE : If nothing wrong with the User ID, try to add the user id in "Users" tab in Endpoints form for that End Point used by the process.
2. Verify the field "Parallel processing" in File System Channel is unchecked.
Basic --> Setup --> AIF --> Channels
We may get the above error if the "Parallel processing" field is set to TRUE(Checked).
3. Try to modify the code in C \ AifInboundParallelMsgProcess\Methods\run ( ).

The code is valid "inboundMsgProcess = new AifInboundMsgProcess(gatewayQueue.data(),
resourceLockId);"
Change From :
"inboundMsgProcess = new AifInboundMsgProcess(gatewayQueue.data(),
resourceLockId);"
Change to :
"inboundMsgProcess = new AifInboundMsgProcess(gatewayQueue,
resourceLockId);"
Hope one of the solutions might work for your issue.
DISCLAIMER This is only an advice to fix this issue, but try this at your own risk.
Happy DAXing
Sai