Monday, 28 April 2014

Step to Create Work flow in ax 2009 (Axpta)



Workflow Installation
A number of the workflow system components are required to be installed before
you can begin to create and configure workflows in Microsoft Dynamics AX.
Workflow website. This is an IIS website that controls the flow of
the workflows.
Workflow accounts. There are two accounts used - a system account
used to provide access to the workflow tables, and an execution
account that is used to execute business logic.
Microsoft Dynamics AX workflow server component. This is the
workflow engine and is installed using the Microsoft Dynamics AX
installation files. The website and the accounts are required to run
this installation.
NOTE: This course does not cover the installation of the workflow system
components; however you need to be aware of the requirements. For more
information about workflow installation, refer to the Administrator Guide.
Create a Workflow Category
A workflow category defines the module in which the workflow will be
available. Modules are defined by the SysModule enum.
Demonstration: Creating a Workflow Category
This demonstration shows you how to create a category that allows the workflow
to be configured from the Projects module.
1. Open the AOT
2. Expand the Workflow node
3. Right-click on the Workflow Category node and select New
Workflow Category. A new workflow category called Workflow
Category1 will be created.
4. Right-click on the newly created workflow category and select
Properties
5. Change the name property to SalesCreditLimitApproval




6. Change the label property to Sales credit limit approval.
7. Change the Module property to Cust.
8. Right-click on the newly created workflow category and select Save.

Create a Workflow Template
A workflow template brings all the different elements of the workflow together.
Workflow configurations are created based on a template, and many
configurations can be based on the same template. The template defines which
actions are allowed and which are required.
Demonstration: Creating a Workflow Template
This demonstration creates a workflow template and binds it to the workflow
category created in the previous demonstration.
1. Open the AOT.
2. Expand the Workflow node.
3. Right-click on the Workflow Templates node and select New
Workflow Template. A new workflow template named
WorkflowTemplate1 will be created.
4. Right-click on the newly created workflow template and select
Properties.



5. Change the name property to SalesCreditLimitApproval.
6. Change the label property to Sales credit limit approval.
7. Change the category property to SalesCreditLimitApproval.
8. Right-click on the newly created workflow template and select Save.

Create a Workflow Document
A workflow document defines what data is affected by the workflow. It can
define one or more tables and all or selected fields on that table. This is done by
using a query.
Demonstration: Creating a Workflow Document
A query defines what tables are used to determine that a workflow can be
initiated. Use a class to bind that query to the workflow template.
1. Open the AOT.
2. Right-click on the Query node and select New Query.
3. Rename the query to SalesCreditLimitApproval.
4. Expand the newly created query.
5. Open another AOT window.
6. Expand Data Dictionary > Tables.



7. Find the table SalesTable.
8. Drag the SalesTable table to the Data Sources node of the
SalesCreditLimitApproval query.
9. Right click on the SalesCreditLimitApproval query and select Save.
10. In the AOT, right-click on the Classes node and select New Class.
11. Copy the following code into the ClassDeclaration.
12. Press F8 to save the method
13. Right-click on the class and select override method >
getQueryName.
14. Copy the following code in to the method.
15. Press F8 to save the method
16. Find the SalesCreditLimitApproval workflow template in the AOT.
17. Right-click on the workflow template and select Properties.
18. In the document property, enter SalesCreditLimitApproval.
19. Right-click on the workflow template and select Save.
class ProjTimeApproval extends workFlowDocument
{
}
QueryName getQueryName()
{
return queryStr(SalesCreditLimitApproval);
}
Create a Workflow Approval
An approval route may contain a number of outcomes. It may be approved,
rejected, returned or a change may be requested. The Workflow Approval
element determines which of these outcomes is allowed and what happens in the
event of each outcome.
Each outcome can trigger specific code by specifying a menu item for each item.
Demonstration: Creating a Workflow Approval
This demonstration creates a workflow approval and specifies how the approval
route can be defined.
1. Open the AOT.
2. Expand the workflow node.
3. Right-click on approvals and select New Approval.
4. Right-click on the newly created approval and select properties.
5. Change the Name property to SalesCreditLimitApproval.
6. Change the Document property to SalesCreditLimitApproval.
7. Change the ParticipantProvider property to
WorkflowUserGroupParticipantProvider.




8. Change the DueDateProvider to
WorkflowWorkCalendarDueDateProvider.
9. Change the HierarchyProvider to WorkflowLimitHierarchyProvider.
10. Change the DocumentMenuItem to SalesTable.
The Providers specify classes that enable rules to be defined for the workflow.
These providers are standard application classes but can be overridden and
modified, or other providers can be used in their place.
FIGURE 11.3
Demonstration: Creating Approval Outcomes
Use a standard class that acts as an engine for all approval outcomes.
You are not required to do anything but set the workflow to either Approved or
Denied, therefore call the same class from two different menu items. The two
menu items simply allow you to use two different labels. In more complex
workflows it may be necessary to override or copy and modify this class rather
than use it directly.
1. Open the AOT.
2. Expand Menu Items.
3. Right-click on Action and select New Menu Item.
4. Right-click on the newly created Action item and select Properties.
5. Change the Name property to SalesCreditLimitApprove.




6. Change the Label property to Approve.
7. Change the ObjectType property to Class.
8. Change the Object property to WorkflowWorkItemActionManager.
9. Right-click on the SalesCreditLimitApprove menu item and select
Save.
10. Right-click on Action and select New Menu Item.
11. Right-click on the newly created Action item and select Properties.
12. Change the Name property to SalesCreditLimitReject.
13. Change the Label property to Reject.
14. Change the ObjectType property to Class.
15. Change the Object property to WorkflowWorkItemActionManager.
16. Right-click on the SalesCreditLimitReject menu item and select
Save.
17. In the AOT, expand Workflow > Approvals >
SalesCreditLimitApproval > Outcomes.
18. Right-click on the Approve node and select Properties.
19. Change the ActionMenuItem property to SalesCreditLimitApprove.
20. Right-click on the Reject node and select Properties.
21. Change the ActionMenuItem property to SalesCreditLimitReject.
22. Right-click on the Deny node and select Properties.
23. Change the Enabled property to No.
24. Right-click on the RequestChange node and select Properties.
25. Change the Enabled property to No
26. Right-click on the SalesCreditLimitApproval approval node and
select Save.




Demonstration: Attaching an Approval to a Template
The approval needs to be attached to the template. This demonstration shows you
how to attach an approval to a template.
1. Open the AOT.
2. Expand Workflow > Workflow Templates >
SalesCreditLimitApproval.
3. Open another AOT window.
4. Expand Workflow > Approvals.
5. Find SalesCreditLimitApproval.
6. Drag the SalesCreditLimitApproval approval to the Required
Elements node of the SalesCreditLimitApproval template.
7. Right-click on the SalesCreditLimitApproval workflow template and
select save.
Enable Workflow on a Form
Now that the workflow template is defined, you can specify which forms will use
this template.
Demonstration: Add a WorkflowState Field
Any form that uses the same table in the datasource as is specified in a workflow
document is able to use that document for workflow. This demonstration shows
how to enable workflow on the Project Hours journal form.
You can specify conditions under which a workflow is eligible for submission.
One of these conditions must be that it has not already been submitted. To test
this condition, use a new field on the SalesTable table.
1. Open the AOT.
2. Expand Data Dictionary.
3. Right-click on Base Enums and select New
4. Rename the new enum to SalesCreditLimitApprovalStatus
5. Add four elements to the Enum called NotSubmitted, Submitted,
Approved, Rejected.
6. Expand Tables > SalesTable.
7. Right-click on Fields and select New > Enum.
8. Right-click on the newly created field and select Properties.
9. Change the Name property to CreditLimitApprovalStatus.
10. Change the EnumType property to SalesCreditLimitApprovalStatus.
11. Right-click on the SalesTable node and select Save.



Demonstration: Enable Workflow on the Form
Workflow on the form is enabled using properties on the design node, and by
overiding a form method. This demonstration shows you how to enable workflow
on a form.
1. Open the AOT.
2. Expand Tables > SalesTable.
3. Create a new method and add the first method in the following code.
4. Save the changes made to the table.
5. Expand Forms > SalesTable > Designs.
6. Right-click on the design node and select Properties.
7. Change the WorkflowEnabled property to Yes.
8. Change the WorkflowDatasource property to SalesTable.
9. Right-click on the form Methods node and select Override
Method > canSubmitToWorkflow.
10. Copy the second method in the following code into the method.
boolean canSubmitToWorkflow()
{
amountMST creditBalance;
custTable custTable;
;
if (!this.CreditLimitApprovalStatus ==
SalesCreditLimitApprovalStatus::NotSubmitted)
return false;
custTable = this.custTable_InvoiceAccount();
if (!custTable.CreditMax)
return false;
creditBalance = custTable.CreditMax -
custTable.balanceMST();
if (this.amountRemainSalesFinancial() +
this.amountRemainSalesPhysical() < creditBalance)
return false;
return true;
}
public boolean canSubmitToWorkflow()
{
return salesTable.canSubmitToWorkflow();
}



The canSubmitToWorkflow method returns true if the ProjJournalTable record
has not already been submitted and the total hours entered in the transactions is
greater than 40.
Demonstration: Create a Submit to Workflow Class
To submit a document to workflow, call standard code to prompt the user for a
comment and to process the submisson. This demonstration shows you how to
create a submit to workflow class.
1. Open the AOT and create a new class.
2. Copy the following code in to the classDeclaration, submit method
and the main method.
3. Press F8 to save and compile the code.
4. Open another AOT and expand Menu Items.
5. Drag the SalesCreditLimitSubmit class to the Actions node.
6. Right-click on the newly created Actions node and select Properties.
7. Change the Label property to Submit.
8. Right-click on the SalesCreditLimitSubmit menu item and select
Save.
9. Locate the workflow template node in the AOT.
10. Right-click and select Properties.
11. Change the SubmitToWorkFlowMenuItem property to
SalesCreditLimitSubmit.
class SalesCreditLimitSubmit
{
}
void submit(Args args)
{
// Variable declaration.
recId recId = args.record().RecId;
WorkflowCorrelationId workflowCorrelationId;
// Hardcoded template name
WorkflowTemplateName workflowTemplateName =
workflowtemplatestr(SalesCreditLimitApproval);
// Initial note is the information that users enter
when they
// submit the document for workflow.
WorkflowComment note ="";
WorkflowSubmitDialog workflowSubmitDialog;
SalesTable SalesTable;
;
// Opens the submit to workflow dialog.
workflowSubmitDialog =
WorkflowSubmitDialog::construct(args.caller().getActiveWork
flowConfiguration());



workflowSubmitDialog.run();
if (workflowSubmitDialog.parmIsClosedOK())
{
recId = args.record().RecId;
SalesTable = args.record();
// Get comments from the submit to workflow dialog.
note = workflowSubmitDialog.parmWorkflowComment();
try
{
ttsbegin;
workflowCorrelationId =
Workflow::activateFromWorkflowTemplate(workflowTemplateName
,
recId,
note,
NoYes::No);
SalesTable.CreditLimitApprovalStatus =
SalesCreditLimitApprovalStatus::Submitted;
// Send an Infolog message.
info("Submitted to workflow.");
ttscommit;
}
catch(exception::Error)
{
info("Error on workflow activation.");
}
}
args.caller().updateWorkFlowControls();
}
public static void main(Args _args)
{
SalesCreditLimitSubmit SalesCreditLimitSubmit
= new SalesCreditLimitSubmit();
;
SalesCreditLimitSubmit.submit(_args);
}



Create Event Handlers
Event handlers are used to execute business logic at specific events in the
workflow. They can be implemented at the workflow level, for example when the
workflow is started or completed, or at an element level, for example when
anyone approves or rejects a step in the approval.
Event handlers are implemented by creating a class that implements one or more
of the EventHandler interfaces. The interfaces at the workflow level are as
follows:
Event Description
WorkflowStartedEventHandler This event raises when the
workflow instance starts.
WorkflowCompletedEventHandler This event raises when the
workflow instance ends after it
is completed.
WorkflowCanceledEventHandler This event raises when the
workflow instance ends after it
is canceled. Use this event
handler to perform any clean
up operations needed.
WorkflowConfigDataChangeEventHandler This event raises when the
workflow configuration data
changes. Use this event
handler to identify when a
configuration has changed. For
example, if you create an
association between the
application data and a
workflow configuration, this
event handler would raise if
the configuration was deleted
or updated.
Demonstration: Add Workflow Level Event Handlers
This demonstration shows you how to add workflow level event handlers.
1. Create a new class. Add the following ClassDeclaration and
methods.
2. Open the properties form for the SalesCreditLimitApproval
workflow template.



3. Set StartedEventHandler, CompletedEventHandler and
CanceledEventHandler properties to SalesCreditLimitEventHandler
class SalesCreditLimitEventHandler implements
WorkflowStartedEventHandler,
WorkflowCanceledEventHandler,
WorkflowCompletedEventHandler
{
}
public void cancelled(WorkflowEventArgs _workflowEventArgs)
{
SalesTable SalesTable;
;
ttsbegin;
select forupdate SalesTable
where SalesTable.RecId ==
_workflowEventArgs.parmWorkflowContext().parmRecId();
SalesTable.CreditLimitApprovalStatus =
SalesCreditLimitApprovalStatus::NotSubmitted;
SalesTable.update();
ttscommit;
}
public void completed(WorkflowEventArgs _workflowEventArgs)
{
SalesTable SalesTable;
;
ttsbegin;
select forupdate SalesTable
where SalesTable.RecId ==
_workflowEventArgs.parmWorkflowContext().parmRecId();
if (salesTable.CreditLimitApprovalStatus ==
SalesCreditLimitApprovalStatus::Submitted)
{
SalesTable.CreditLimitApprovalStatus =
SalesCreditLimitApprovalStatus::Approved;
SalesTable.update();
}
ttscommit;
}



public void returned(WorkflowEventArgs _workflowEventArgs)
{
SalesTable SalesTable;
;
ttsbegin;
select forupdate SalesTable
where SalesTable.RecId ==
_workflowEventArgs.parmWorkflowContext().parmRecId();
SalesTable.CreditLimitApprovalStatus =
SalesCreditLimitApprovalStatus::Rejected;
SalesTable.update();
ttscommit;
}
public void started(WorkflowEventArgs _workflowEventArgs)
{
SalesTable SalesTable;
;
ttsbegin;
select forupdate SalesTable
where SalesTable.RecId ==
_workflowEventArgs.parmWorkflowContext().parmRecId();
SalesTable.CreditLimitApprovalStatus =
SalesCreditLimitApprovalStatus::Submitted;
SalesTable.update();
ttscommit;
}



Element Level Event Handlers
The interfaces at the workflow element level are as follows:
Event Description
WorkflowElementStartedEventHandler This event raises when the
task or approval starts.
For approvals, you can use
this event to transition the
workflow document state
from Submitted to
PendingApproval.
WorkflowElementCanceledEventHandler This event raises when the
task or approval is canceled.
For approvals, you can use
this event to transition the
workflow document state
from the current state to
Canceled.
WorkflowElementCompletedEventHandler This event raises when the
task or approval is completed.
For approvals, you can use
this event to transition the
workflow document state
from PendingApproval to
Approved.
WorkflowElementReturnedEventHandler This event raises when the
task or approval is returned to
the originator.
For approvals, you can use
this event to transition the
workflow document state
from the current state to
RequestChange.
WorkflowElemChangeRequestedEventHandler This event raises when an
approver requests a change to
the task or approval.
For approvals, you can use
this event to transition the
workflow document state
from PendingApproval to
RequestChange.



Demonstration: Add Element Level Event Handlers
This demonstration shows you how to add element level event handlers.
1. Create a class and add the following ClassDeclaration and methods.
2. Find the SalesCreditLimitApproval Workflow Approval element
3. Expand the node and open the properties for the Reject node.
4. Set the EventHandler property to SalesCreditLimitElementHandler
class SalesCreditLimitElementHandler implements
WorkflowElementCompletedEventHandler,
WorkflowElementCanceledEventHandler,
WorkflowElementReturnedEventHandler,
WorkflowElemChangeRequestedEventHandler,
WorkflowElementStartedEventHandler
{
}
public void returned(WorkflowEventArgs _workflowEventArgs)
{
SalesTable SalesTable;
;
ttsbegin;
select forupdate SalesTable
where SalesTable.RecId ==
_workflowEventArgs.parmWorkflowContext().parmRecId();
SalesTable.CreditLimitApprovalStatus =
SalesCreditLimitApprovalStatus::Rejected;
SalesTable.update();
ttscommit;
}



Configure a Workflow
Now that you have created a template and enabled it on a form, you can
configure it for use.
Demonstration: Configuring a Workflow
This demonstration shows you how to configure a workflow from the main
menu.
1. Open the main menu and select Accounts Receivable > Setup >
Workflow configurations.
2. Click New.
3. Select Sales credit limit approval and click Create configuration.
4. Enter "Credit limit approval" as the name.
5. Click Create Instruction, enter "Please approve" and then click OK.
6. Click the Details tab, expand SalesCreditLineApproval, and click on
Step 1.
7. Under Step details, click on Assignment tab.
8. Click the Choose button.
9. Select User based, enter a user in the Select users field and then click
OK.
10. Close the approval form.
11. On the configuration form click Set as active.
12. Click the Overview tab.
13. Click Set as default.
The workflow is now ready for use.
Demonstration: Test the Workflow
This demonstration shows you how to can test the workflow by creating a
timesheet
1. Select a customer from the customer table and set a credit limit.
2. Create a new sales order and create lines such that the balance of the
customer plus the total amount on the lines is greater than the credit
limit.
3. The workflow submit button and dialog should appear.
4. Click the submit button and enter a comment.
5. Open the AOT.
6. Expand the Forms node.
7. Find the form Tutorial_WorkFlowProcessor.
8. Right-click on this form and select Open.
9. Click Start.



10. When the form says that it has zero records in queue, click Stop and
go back to the sales table form.
11. Select Actions > History. You will see that the document is waiting
for approval by the person you assigned to approve it.
12. Logon as the user who should approve the sales order
13. Open the sales order form.
14. Click the workflow Actions button and select Approve.
15. Open the Tutorial_WorkflowProcessor form again and click Start,
wait for it to complete and click Stop.
16. The workflow has now been approved.



 - Add Another Condition to the Submit Action
Scenario
Isaac has been asked to ensure that, once a credit limit has been reached, the sales
order cannot be posted until the workflow has been approved.
Challenge Yourself!
Add conditions to the posting functions on the sales order form that will prevent
posting to picking, packing or invoicing until the workflow has been approved. If
the credit limit has not been reached, then the postings should be allowed.
Step by Step
1. Add the following method CanPostCreditLimit to the salesTable
table.
2. Add the following code to the methods canPickingListBeUpdate(),
canPackingSlipBeUpdated() and canInvoiceBeUpdated() in the
salesTableType class.
boolean canPostCreditLimit()
{
amountMST creditBalance;
custTable custTable;
;
if (this.CreditLimitApprovalStatus ==
SalesCreditLimitApprovalStatus::Approved)
return true;
if (this.CreditLimitApprovalStatus ==
SalesCreditLimitApprovalStatus::Rejected
|| this.CreditLimitApprovalStatus ==
SalesCreditLimitApprovalStatus::Submitted)
return false;
custTable = this.custTable_InvoiceAccount();
if (!custTable.CreditMax)
return true;
creditBalance = custTable.CreditMax -
custTable.balanceMST();
if (this.amountRemainSalesFinancial() +
this.amountRemainSalesPhysical() < creditBalance)
return true;
return false;




}
boolean canPickingListBeUpdated()
{
......
ok = ok && salesTable.canPostCreditLimit();
return ok;
}
boolean canPackingslipBeUpdated()
{
......
ok = ok && salesTable.canPostCreditLimit();
return ok;
}
boolean canInvoiceBeUpdated()
{
......
ok = ok && salesTable.canPostCreditLimit();
return ok;
}
Code Walkthrough: Submitting a workflow
When a record is submitted to workflow, the main() method in the submit to
workflow class is called.
1. View the ProjTimeApprovalsSTWF.main() method created in the
Create A Submit to Workflow Class demonstration. The user is
prompted for a comment while submitting the workflow
workflowSubmitDialog =
WorkflowSubmitDialog::construct(args.caller().getActiveWork
flowConfiguration());
workflowSubmitDialog.run();




The record is retrieved from the calling form and the recId is passed to the static
method Workflow::activateFromWorkflowTemplate(), which runs the submit
process.
ProjJournalTable = args.record();
// Get comments from the submit to workflow dialog.
_initialNote = workflowSubmitDialog.parmWorkflowComment();
try
{
ttsbegin;
// Activate the workflow.
_workflowCorrelationId =
Workflow::activateFromWorkflowTemplate(_workflowTemplateNam
e, _recId, _initialNote, NoYes::No);
2. View the method Workflow::activateFromWorkflowTemplate()
tableId =
Workflow::getDocumentTableId(_workflowTemplateName);
configTable =
Workflow::findWorkflowConfigToActivateForTemplate(_workflow
TemplateName, _recId, tableId);
The tableId that the workflow is to be performed on is retrieved from the query
specified in the workflow document class.
The workFlowContext class holds all the relevant data for the workflow
submission. The SysWorkFlowEventDispatcher class creates records that will be
read by the Workflow Processor class to determine which actions should be
executed in the next step of the workflow.
workflowContext =
WorkflowContext::newRootWorkflowContext(curext(), tableId,
_recId, correlationId);
try
{
SysWorkflowEventDispatcher::onWorkflowSubmit(workflowContex
t, _submittingUser, configTable.ConfigurationId,
_initialNote, _activatingFromWeb);
}
3. Return to the ProjTimeApprovalsSTWF.main() method
ProjJournalTable.WorkFlowState = true;
The journal is marked as submitted.




Code Walkthrough: Workflow Processor
All workflows are processed through a batch process. To view a simulation of
how the workflows are processed, use the form Tutorial_WorkflowProcessor.
1. View the form method doMessageProcessing on the form
Tutorial_WorkflowProcessor.
while select workflowWorkItemTable where
workflowWorkItemTable.Type ==
WorkflowWorkItemType::WorkItem &&
(workflowWorkItemTable.Status ==
WorkflowWorkItemStatus::Pending ||
workflowWorkItemTable.Status ==
WorkflowWorkItemStatus::Delegated) &&
workflowWorkItemTable.DueDateTime <
DateTimeUtil::getSystemDateTime()
{
WorkflowWorkItem::escalateWorkItem(SysWorkflowWorkItemConte
xt::newWorkflowWorkItemContextFromWorkItem(workflowWorkItem
Table));
cntWorkItems++;
}
All records due for processing are retrieved. The
WorkflowWorkItem::escalateWorkItem() is called
2. View the method WorkflowWorkItem::escalateWorkItem()
try
{
workItemId =
SysWorkflowEventDispatcher::onWorkItemEscalation(_workItemC
ontext);
}
3. View the method
SysWorkflowEventDispatcher::onWorkItemEscalation()
workItemTable =
WorkflowWorkItemTable::findPendingActivityInstanceId(_workI
temContext.parmWorkflowActivityInstanceKey().parmWorkflowAc
tivityInstanceId(), true);
The workItemTable record is retrieved. This is the next pending activity on the
workflow, based on the configuration.




The action to be performed is examined
switch (stepTable.EscalationType)
{
case WorkflowEscalationType::Action:
workItemInstanceId = workItemTable.Id;
The next step is completed.
workItemTable.Status =
SysWorkflowEventDispatcher::completeWorkItem(
_workItemContext,
workItemTable,
stepTable.EscalationAction,
workItemTable.UserId,
workflowTable.Originator, // always set the autoescalate
user to the workflow originator
"@SYS110277");

- Enable Resubmit
Scenario
Issac is required to ensure the workflow can be resubmitted after it has been
rejected.
Challenge Yourself!
When a workflow is rejected, it should be able to be resubmitted. Modify the
Submit to Workflow class so that it can resubmit the workflow after a rejection
Use the PurchReqWorkflow class as inspriration.
Step by Step
1. Create a new action menu item called SalesCreditLimitResubmit
2. Set the ObjectTypePropety to class, the Object property to
SalesCreditLimitSubmit and the Label property to Resubmit.
3. Modify the Main method on the SalesCreditLimitSubmit class and
add a new method Resubmit as follows:
4. On the SalesCreditLimitApproval approval element, set the
ResubmitMenuItem property to SalesCreditLimitResubmit
public static void main(Args _args)
{
SalesCreditLimitSubmit SalesCreditLimitSubmit
= new SalesCreditLimitSubmit();
;
if (_args.menuItemName() ==
menuitemactionstr(SalesCreditLimitSubmit))
{
SalesCreditLimitSubmit.submit(_args);
}
else
{
SalesCreditLimitSubmit.resubmit(_args);
}
}
void resubmit(Args args)
{
// Variable declaration.
recId _recId = args.record().RecId;
WorkflowCorrelationId _workflowCorrelationId;
// Hardcoded template name
WorkflowTemplateName _workflowTemplateName =
workflowtemplatestr(SalesCreditLimitApproval);



// Initial note is the information that users enter
when they
// submit the document for workflow.
WorkflowComment _initialNote ="";
WorkflowWorkItemActionDialog
WorkflowWorkItemActionDialog;
SalesTable SalesTable;
;
// Opens the submit to workflow dialog.
workflowWorkItemActionDialog =
WorkflowWorkItemActionDialog::construct(
args.caller().getActiveWorkflowWorkItem(),
WorkflowWorkItemActionType::Resubmit,
new
MenuFunction(menuitemactionstr(PurchReqReSubmit),
MenuItemType::Action));
workflowWorkItemActionDialog.run();
if (WorkflowWorkItemActionDialog.parmIsClosedOK())
{
_recId = args.record().RecId;
SalesTable = args.record();
// Get comments from the submit to workflow dialog.
_initialNote =
workflowWorkItemActionDialog.parmWorkflowComment();
try
{
ttsbegin;
WorkflowWorkItemActionManager::dispatchWorkItemAction(
args.caller().getActiveWorkflowWorkItem(),
_initialNote,
curUserId(),
WorkflowWorkItemActionType::Resubmit,
args.menuItemName(),
false);
SalesTable.CreditLimitApprovalStatus =
SalesCreditLimitApprovalStatus::Submitted;
// Send an Infolog message.
info("Resubmitted to workflow.");



ttscommit;
}
catch(exception::Error)
{
info("Error on workflow activation.");
}
}
args.caller().updateWorkFlowControls();
}
********************************************************
Summary
The workflow module is a highly configurable and flexible module. However, by
using Morph X and some standard code templates, it can be configured for any
part of the Microsoft Dynamics AX application.
This lesson explores some of the possibilities the workflow framework offers,
and explores some of the different ways it can be used to cover most workflow
requirements.



 Knowledge

Solutions
1. Which application element is used to define to which module a workflow is
applicable?
( ) Workflow template
() Workflow category
( ) A field in the workflow configuration
( ) SalesTable
2. Which type of AOT element needs to be created to specify which tables will
be affected by a workflow?
( ) Extended data type
( ) Class
( ) Form
() Query
3. There are three types of providers that define what rules the workflow can
follow. What are they?
() Participant provider
() DueDate provider
() Hierarchy provider
( ) Internet provider
4. Which two properties on a form data source need to be modified to allow the
form to use a workflow?
( ) WorkflowTemplate
() WorkflowEnabled
( ) WorkflowDocument
() WorkflowDatasource






No comments:

Post a Comment

Labels

#veryusefulcode (1) AIF (8) AOT Maps (1) Args (1) Ax 2009 Reports (2) AX 2012 navigation (1) Ax 2012 Interview Questions (1) AX 7 (2) AX Architecture (1) Ax Backup (1) AX Workflow (2) AX2012 (1) AX2012 R2 (1) Ax2012R3 (1) AX2012R3 Dynamics Connector Step by Step Installation and Configuration (1) AX2012R3 EP Step by Step Installation and Configuration EP R3 (1) AX2012R3 HelpServer Step by Step Installation and Configuration (1) AX2012R3 Rapid Start Connector Step by Step Installation and Configuration (1) AX2012R3 Report Server and Analysis Server Step by Step Installation and Configuration (1) AX7 (1) Best practices (1) Blocking user to enter (1) Collection Classes (1) Container (1) D365FO (3) Data Migration Frame Work ax 2012R3 (1) Deleting duplicate Record from Table – Ax2012 (1) Delivery due date notification workflow in Ax 2012 (1) Development Steps EP (1) Dimensions (1) DIXF (1) DMF in Ax 2012 R3 (1) Dynamics Ax 2012 Interview Questions (1) DYNAMICS AX 2012 INTERVIEW QUESTIONS PART 2 (1) DYNAMICS AX 7 (1) EDT relation Migration Tool (1) EP AX 2012 (1) Ep Lookup (1) Error (1) Event Handler (1) F5 (1) File Handling (4) Filter on AX2012 Listpage (1) filtering (2) financial dimensions in AX 2012 (3) form (1) images (1) Installation and Configration (4) Installation and Configuration (11) Installation of Management Reporter 2012 for AX 2012 (1) Interaction class in ax 2012 (1) Interview Question (1) Interview Questions For Ax 2012 (1) Invent DIm (1) Jobs (2) license (1) List page and form menuitem enable code (1) Methods (1) microsoft Dynamics AX 365FO (1) Number Sequence Generation – AX 2012 (5) Number Sequence2012 (1) OLTP-OLAP (1) Passing Args (1) Passing form caller and menu item caller in ax 2012 (1) Passing Multiple Records Args (1) Posting in Ax 2012 (1) POSTING PURCHASE ORDER (1) Query (1) Query Filter Form (2) Query Ranges in X++ (1) Question and Answer (1) Report (1) Reports Controller class (1) RLS in ax 2009 (1) SALES ORDER IMPORT/EXPORT FRAMEWORK BY DMF (1) Security (1) security roles (1) Security Sysqueryrangeutil (1) Sharepoint 2016 (1) SQL SERVER (1) SSRS (2) SSRS Reports Controller class (2) Table collections & Virtual company (1) Time (1) TIPS AND TRICKS (1) Web service AIF (3) Web Services on IIS (AIF) Step by Step Installation and Configuration (1) workflow ax2012 (1) Workflow installation (1) Workflow Method (3) X++ (1)