web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Approval multiple Workflow activities at once

(0) ShareShare
ReportReport
Posted on by 1,683

I received a new required to allow users to accept/refuse multiple workflow activities by one clicking.

Modified 'TimeSheetApprovoal' user control to allow multiple selecting:

0118.ep_2D00_approv_2D00_2.jpg

Now when I select 2 lines the button 'Actions' of workflow bar is hidden and multiple lines cannot be approved/rejected.

For one line the button is displayed:

Which ax classes  I have to modify to allow actions for multi lines select?

Where I can find some info about how Workflow works in Enterprise portal?

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Axapta 2012 - Enterprise Portal - Approval multiple Workflow activities at once.

    Hey Adrian,

    Did u manage to get it to work? We have similar requirement and tryng to find the best way to proceed with it.

    Thanks,

    Nitin

  • Arun2012AX Profile Picture
    15 on at
    RE: Axapta 2012 - Enterprise Portal - Approval multiple Workflow activities at once.

    Hi guys,

    does u people got solution for this??????

    if yes, plz post it here.

    thanx in advance....

  • Suggested answer
    Jonathan  Halland Profile Picture
    11,310 on at
    RE: Axapta 2012 - Enterprise Portal - Approval multiple Workflow activities at once.

    Hi Adrian. You will struggle to do this via the standard yellow workflow bar as each workitem could be executing a different menu-item due to different steps, configs etc. We added buttons to the task bar for core actions "Approve" and "Reject".

    Please message me with your email address and I'll send you code.

    public static void actionItem(WorkflowWorkItemActionType action, WorkflowWorkItemTable _workitem, WorkflowComment _comment,MenuItemName _menuItem )
    {
       WorkflowWorkItemActionManager::dispatchWorkItemAction(_workitem,
                                                                    _comment,
                                                                    '',
                                                                    action,
                                                                    _menuItem,
                                                                    false);
        info("Item Actioned");
    }
    
    public static void main(Args args)
    {
        FormDataSource ds = Args.record().dataSource();
        Common record;
        WorkflowWorkItemTable workitem;
        WorkflowComment comment;
        MenuItemName menuitem;
        str label;
        WorkflowWorkItemActionType action;
        boolean commented;
        WorkflowWorkItemActionDialog dialog;
    
        action = args.parmEnum();
    
        for(record = ds.getFirst(true) ? ds.getFirst(true) : ds.cursor(); record; record = ds.getNext())
        {
            workitem = MultipleApprover::getActiveWorkitemForRecord(record);
            if (workitem)
            {
                [menuitem,Label] = MultipleApprover::getMenuItemForType(workitem, action, curUserId());
                if (!commented)
                {
                    dialog = WorkflowWorkItemActionDialog::construct(workitem, action, new MenuFunction(menuitem, MenuItemType::Action));
                    dialog.run();
                    if (dialog.parmIsClosedOK())
                    {
                        commented = true;
                        comment = dialog.parmWorkflowComment();
                    }
                    else
                    {
                        break;
                    }
                }
                if (menuitem)
                {
                    MultipleApprover::actionItem(action, workitem,comment,menuitem);
                }
                else
                {
                    error(strFmt("No %1 action defined for item %2", action, record.caption()));
                }
            }
        }
        ds.research();
        ds.refresh();
    }
    
    public static container getMenuItemForType(WorkflowWorkItemtable _workitem, WorkflowWorkItemActionType _type, UserId user)
    {
        #Workflow
    
        WorkflowElementTable    workflowElement;
        SysDictWorkflowElement  dictWorkflowElem;
    
        WorkflowConfigOutcome   workflowConfigOutcome;
        WorkflowWorkItemActionType  workItemActionType;
    
        Map                         actionList;
        MapEnumerator               actionListEnum;
        Map                         outcomeList;
        MapEnumerator               outcomeListEnum;
    
        SysDictMenu             sysDictMenu;
    
         MenuItemName               mi;
         //MenuItemName               ret;
         container ret = ["",""];
        ;
        if (_workitem.Type != WorkflowWorkItemType::Recall)
        {
            workflowElement = WorkflowElementTable::find(_workitem.ElementId);
            if (workflowElement.RecId != 0)
            {
                dictWorkflowElem = new SysDictWorkflowElement(workflowElement.ElementType, workflowElement.ElementName);
    
                if (_workitem.Type == WorkflowWorkItemType::RequestChange || _workitem.Type == WorkflowWorkItemType::Return)
                {
                    //ADD RESUBMIT ITEMS
                    mi = dictWorkflowElem.resubmitMenuItem();
                    sysDictMenu = SysDictMenu::newMenuItem(mi,MenuItemType::Action);
                    if (_type == WorkflowWorkItemActionType::Resubmit)
                    {
                        ret = [mi, sysDictMenu.label()];
                        return ret;
                    }
                }
                else
                {
    
                    workflowConfigOutcome = workflowElement.getElementOutcomes();
    
                    actionList = workflowConfigOutcome.parmActionList();
                    actionListEnum = actionList.getEnumerator();
    
                    outcomeList = workflowConfigOutcome.parmOutcomList();
                    outcomeListEnum = outcomeList.getEnumerator();
    
                    while (outcomeListEnum.moveNext())
                    {
                        if (outcomeListEnum.currentValue() == NoYes::Yes)
                        {
                            mi = dictWorkflowElem.actionMenuItem(outcomeListEnum.currentKey());
                            sysDictMenu = SysDictMenu::newMenuItem(mi,MenuItemType::Action);
                            workItemActionType = WorkflowWorkItemActionManager::findActionTypeForMenuItem(_workitem, mi, false);
                            if (workItemActionType == _type)
                            {
                                if (sysDictMenu)
                                {
                                    ret = [mi, sysDictMenu.label()];
                                    break;
                                }
                            }
                        }
                    }
    
                    if (_type == WorkflowWorkItemActionType::Delegate)
                    {
                        while (actionListEnum.moveNext())
                        {
                            // make sure action is enabled
                            if (actionListEnum.currentValue() == NoYes::Yes)
                            {
                                if (actionListEnum.currentKey() == #WorkflowWorkItemActionDelegate)
                                {
                                    // allow delegate if work item is not a final approver work item
                                    if (_workitem.Type != WorkflowWorkItemType::FinalApprover)
                                    {
                                        mi = dictWorkflowElem.delegateMenuItem();
                                        sysDictMenu = SysDictMenu::newMenuItem(mi,MenuItemType::Action);
                                        ret = [mi, sysDictMenu.label()];
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return ret;
    }
    
    public static WorkflowWorkitemTable getActiveWorkitemForRecord(Common _buffer)
    {
        WorkflowWorkitemTable workitem;
        RecId refRecid = _buffer.RecId;
        TableId refTableId = _buffer.TableId;
    
        select workitem where workitem.RefRecId == refRecid && workitem.RefTableId == refTableId
            && (workitem.Status == WorkflowWorkItemStatus::Pending || workitem.Status == WorkflowWorkItemStatus::Delegated);
    
        return workitem;
    }


  • Tahseen Ahmed Profile Picture
    10 on at
    RE: Axapta 2012 - Enterprise Portal - Approval multiple Workflow activities at once.

    Hi, I have same requirement as well, can you please email me the code , xpo file. [address removed by moderator]

    Thanks,

    Tahseen

  • Community Member Profile Picture
    on at
    RE: Axapta 2012 - Enterprise Portal - Approval multiple Workflow activities at once.

    [quote user="Adrian Pascari A"]

    I received a new required to allow users to accept/refuse multiple workflow activities by one clicking.

    Modified 'TimeSheetApprovoal' user control to allow multiple selecting:

    0118.ep_2D00_approv_2D00_2.jpg

    Now when I select 2 lines the button 'Actions' of workflow bar is hidden and multiple lines cannot be approved/rejected.

    For one line the button is displayed:

    Which ax classes  I have to modify to allow actions for multi lines select?

    Where I can find some info about how Workflow works in Enterprise portal?

    [/quote]

  • Community Member Profile Picture
    on at
    RE: Axapta 2012 - Enterprise Portal - Approval multiple Workflow activities at once.

    Please forward me the code at [removed by moderator].

  • lachea Profile Picture
    10 on at
    RE: Axapta 2012 - Enterprise Portal - Approval multiple Workflow activities at once.

    [removed by moderator] if you still have it available.  This looks like exactly what I am looking for, I've reviewed the code above that should give me a much needed push in the right direction.  Thanks much!

  • Community Member Profile Picture
    on at
    RE: Axapta 2012 - Enterprise Portal - Approval multiple Workflow activities at once.

    Please forward the code to [removed by moderator] as well, if it is still available.

    I also have a request similar to this for custom forms.

    I'm not sure if a custom line-item workflow will accomplish this.

    Thnaks

  • Pradeep_Prakash Profile Picture
    717 on at
    RE: Axapta 2012 - Enterprise Portal - Approval multiple Workflow activities at once.

    I have exact requirement on the client. Can you please me the code as soon as possible.

    Thanks in advance.

    Pradeep

  • Pradeep_Prakash Profile Picture
    717 on at
    RE: Axapta 2012 - Enterprise Portal - Approval multiple Workflow activities at once.

    Anybody has this code. Can you guys, please send me it to the below mail Id. Its Critical!!

    [address removed by moderator]

    Regards,

    Pradeep

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans