Tuesday, January 8, 2019

Workflow Mass Reassign users

static void AXworkflowMassReassign(Args _args)
{
    userid src,dest;
    name comment;
    WorkflowWorkItemSubject subject;
    WorkflowConfigurationName confignme;
    WorkflowSequenceNumberActive congifId;
    dialogfield srcdf,destdf,comtdf,subjectDf,congifIdDf,confignamedf;
    dialog dialog;
    WorkflowWorkItemTable workitems;
    WorkflowTrackingStatusTable WorkflowTrackingStatusTable;

    WorkflowConfigurationTable WorkflowConfigurationTable;
    boolean isFieldModified;





    int i;
    ;
    dialog = new dialog("Mass Re-assign workflow ");
    srcdf = dialog.addField(typeid(userid),"Source");
    destdf = dialog.addField(typeid(userid),"Destination");
    comtdf = dialog.addField(typeid(name),"Comments");
    congifIdDf = dialog.addField(typeid(WorkflowSequenceNumberActive),"Configuration Id");
   // confignamedf = dialog.addFieldValue(typeid(name),"","Configuration name");
    subjectDf = dialog.addField(typeid(WorkflowWorkItemSubject),"Subject");
    comtdf.displayLength(50);
  //  confignamedf.allowEdit(false);




     if(dialog.run())
    {
        src = srcdf.value();
        dest = destdf.value();
        comment =comtdf.value();
        congifId = congifIdDf.value();
        subject = subjectdf.value();
        WorkflowConfigurationTable = WorkflowConfigurationTable::findSequenceNumber(congifId,false);

        if(src!="" && dest !="")
        {

            if(subject == "" && congifId == "" )
            {
            while select workitems where workitems.Status == WorkflowWorkItemStatus::Pending
            && workitems.UserId == src

                {
                    WorkflowWorkItem::delegateWorkItem(workitems.Id, dest, comment);
                    i++;
                }
            }


            if(congifId != "" && subject == "")
            {
              while select workitems where
              workitems.Status == WorkflowWorkItemStatus::Pending &&
               workitems.UserId == src
              && workitems.ConfigurationId == WorkflowConfigurationTable.ConfigurationId
                {
                    WorkflowWorkItem::delegateWorkItem(workitems.Id, dest, comment);
                    i++;
                }
            }




            if(subject != "" && congifId == "" )
            {
                while select workitems where workitems.Status == WorkflowWorkItemStatus::Pending && workitems.UserId == src
                 && workitems.subject == subject
                {
                    WorkflowWorkItem::delegateWorkItem(workitems.Id, dest, comment);
                    i++;
                }
             }



            info(strFmt("Pending workflow workitems  re-assigned: %1",i));
        }
    }
    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...