Professional Documents
Culture Documents
D365 FO and AX 2012 Technical Discussion Workflow in Ax 2012 Complete
D365 FO and AX 2012 Technical Discussion Workflow in Ax 2012 Complete
3. Right-click on the Workflow Templates node and select New List Page Interaction Class and Methods in ax 2012
Workflow Template. A new workflow template named Listpage interaction class and methods Interaction
WorkflowTemplate1 will be created. class of list pages extends SysListPageInteractionBase
4. Right-click on the newly created workflow template and select class. Some handful methods of...
Properties.
Workflow in ax 2012 complete
Microsoft Official Training Materials for Microsoft Dynamics ®
WORKFLOW Objectives The objectives are: • Identify
Your use of this content is subject to your current services agreement
the components required prior to using workflow •
Specify which application modu...
5. Change the name property to SalesCreditLimitApproval.
6. Change the label property to Sales credit limit approval. Failed to create a session, confirm that the user has
7. Change the category property to SalesCreditLimitApproval. the proper privileges to log on to Microsoft Dynamics in
ax 2012
8. Right-click on the newly created workflow template and select Save.
While running system Administration > Setup >
FIGURE 11.2
Workflow > Workflow infrastructure configuration Error:-
Failed to create a sessi...
Create a Workflow Document
A workflow document defines what data is affected by the workflow. It can What is Model and ModelStore in ax 2012
define one or more tables and all or selectedfields on that table. This is done by Basic Info: Models were introduced in Microsoft
using a query. Dynamics AX to help partners and customers more
easily install and maintain multiple soluti...
Demonstration: Creating a Workflow Document How to check Permission Access of AX file in ax 2012
A query defines what tables are used to determine that a workflow can be Super Tips for Testing Dynamics AX File Permission
initiated. Use a class to bind thatquery to the workflow template. Access Batch processes which use file input are very
1. Open the AOT. common designs in Dynamics AX, ...
2. Right-click on the Query node and select New Query.
SSRS Report Deployment failed - The
3. Rename the query to SalesCreditLimitApproval. number of defined parameter is not
4. Expand the newly created query. equal to the number of cell definitions in
5. Open another AOT window. the parameter panel. in d365fo
6. Expand Data Dictionary > Tables. Report deployment parameter Error
Microsoft Official Training Materials for Microsoft Dynamics ® Error: - The number of defined parameter is not equal
Your use of this content is subject to your current services agreement to the number of cell definitions in the parameter...
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());
Microsoft Official Training Materials for Microsoft Dynamics ®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
11-11
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);
}
Microsoft Official Training Materials for Microsoft Dynamics ®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics
®
AX2009
11-12
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
workflow configuration data
changes. Use this event
®
AX2009
11-18
10. When the form says that it has zero records in queue, click Stopand
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 Actionsbutton 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.
Microsoft Official Training Materials for Microsoft Dynamics ®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
11-19
Lab 11.1 - 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;
Microsoft Official Training Materials for Microsoft Dynamics ®
Your use of this content is subject to your current services agreement
Development IV in Microsoft Dynamics
®
AX2009
11-20
}
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();
Microsoft Official Training Materials for Microsoft Dynamics ®
Your use of this content is subject to your current services agreement
Chapter 11: Workflow
11-21
The record is retrieved from the calling formand 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 =
_workflowCorrelationId =
Workflow::activateFromWorkflowTemplate(_workflowTemplateNam
2 comments:
Hi,
I have a catalogue configured in my system where after import there is an Automated approval system in place to approve the product. I have
close to 1000 items in one file .
The problem I am facing is that workflow error out during the approval , when we resume it approves some more item and then again error out,
the error i am getting in event log is one of below
X++ Exception: Cannot save the workflow because affinity does not match.
at SysWorkflow-save
SysWorkflowQueue-resume
Any idea about this issue, please suggest. Appreciate any help
Reply
Replies
Reply
Reply
Powered by Blogger.