Pages

Monday, November 7, 2016

Workflow: Create custom work item queue

1) First:  CustomXXX document is not available for selection in the work item queue.  See below.

To fix this we simply need an attribute on the workflow document class.  i.e
 [WorkflowDocIsQueueEnabledAttribute(true, "CustomXXX")]
class CustomXXXWorkflowDocument extends WorkflowDocument
{
}

Now we can create a work item queue based on this document.

2) The answer to this was to create the following class:
 class CustomXXXTaskCreatedEventHandler extends WorkflowQueueCreatedEventHandler
{
}
                             
protected void mapFields()
{
     #Workflow

    CustomXXX   CustomXXX;
    WorkflowDocIsQueueEnabledAttribute attribute;
    DictClass       dictClass;

    dictClass = new DictClass(classNum(CustomXXXDocument));
    attribute = dictClass.getAttribute(#WorkflowDocumentAttribute);

    CustomXXX = CustomXXX::findRecId(this.parmWorkflowWorkitemTable().RefRecId);

    this.parmDocumentId(CustomXXX.CustomXXXId);
    this.parmDocumentType(attribute.parmFriendlyName());
    this.parmCompanyInfo(CustomXXX.company());
}

HB: This was based on classes\PurchTableTaskCreatedEventHandler.

This class extends WorkflowQueueCreatedEventHandler which in turn implements WorkflowWorkItemsCreatedEventHandler.
In order to trigger this event you must point the workflow tasks to the above class.
Find the task under AOT/Workflow/Tasks.  Look for the property WorkItemsCreatedEventHandler.  Put the name of your event handler in here. (in my case CustomXXXTaskCreatedEventHandler).

Please go home/Work Items/ Work items assigned to my queues...

thanks David for topic  : https://community.dynamics.com/ax/f/33/t/126896


0 yorum:

Post a Comment