Sunday, May 15, 2016

Replace Assigned workflow user In AX 2009 without changing Configuration Id

static void AXReplaceAssignedworkflowuser(Args _args)
{
    userid src,dest;
    dialogfield srcdf,destdf;
    dialog dialog;
    WorkflowStepTable   WorkflowStepTable;
    container               con;

    ;
    dialog = new dialog("Replace workflow assigned Approval user");
    srcdf = dialog.addField(typeid(userid),"Source");
    destdf = dialog.addField(typeid(userid),"Destination");
    if(dialog.run())
    {
        src = srcdf.value();
        dest = destdf.value();
        if(src!="" && dest !="")
        {
        ttsbegin;
        while select forupdate WorkflowStepTable
        {
             con = WorkflowStepTable.AssignTo;
             if(conpeek(con,4) == src)
             {
                info(strfmt("Before update userid  %1 ",conpeek(con,4)));

                con = conpoke(con,4,dest);

                WorkflowStepTable.AssignTo = con;
                WorkflowStepTable.doUpdate();


                info(strfmt("after update userid  %1 ",conpeek(con,4)));
             }
        }
         info("Workflow approval user has been replaced !.");
        ttscommit;
        }
    }
    else
    {
        info("Canceled by user");
    }


}

No comments:

Post a Comment

Sending Email using X++ Code in D365 F&O/ AX 7 in HTML fomat

  I was just researching on the emailing capabilities in D365 and found that SysINetMail, SysMailer and some of the smmOutlook classes are d...