Search This Blog

Thursday, April 20, 2017

AX2012 Update AIF Port adresses

When we export from one environmen to another we should update the port addresses to the new environment addresses.
Like moving from config environmen to SIT, QA..etc.


static void krishh_UpdateAddressForPorts(Args _args)
{
    AifChannel  aifchannel;
    str         fromPath, toPath;
    boolean     Update;

    Dialog      dialog;

    DialogField _from;
    DialogField _to;
    dialogField _Update
    ;

    dialog = new Dialog("Move configdata");

    dialog.addInfoImage();
    dialog.addText("This job changes all paths on inbound and outbound ports!!!");

    dialog.addGroup("Paths");
    _from   = dialog.addField(ExtendedTypeStr(String255), "From enviroment" , "Normally from MasterConfigData (CFG)"     );
    _to     = dialog.addField(ExtendedTypeStr(String255), "To enviroment"   , "Valid enviroments are SIT, UAT, QA & PROD");
    dialog.addGroup("Update");
    _Update = dialog.addField(ExtendedTypeStr(NoYesId)  , "Commit change"          , "Update the changes");

    //InitValues
    _from.value("CFG");
    _Update.value(false);

    dialog.run();

    fromPath = _from.value();
    toPath   = _to.value();

    if ((!fromPath || !toPath) || (fromPath == toPath))
    {
        return;
    }

    ttsBegin;
    while select forupdate aifchannel where aifchannel.Direction != AIFChannelDirection::Both
    {
        if (strScan(aifchannel.TransportAddress, fromPath, 1, 255))
        {
            aifchannel.TransportAddress=strReplace(aifchannel.transportAddress, fromPath, toPath);
            info(aifchannel.TransportAddress);

            if (_Update)
             aifchannel.update();
        }
    }
    ttsCommit;
}

No comments:

Post a Comment

Thanks for visiting my blog,
I will reply for your comment within 48 hours.

Thanks,
krishna.