Tuesday, 10 May 2016

AX 2012 Issue: Missing module in Dynamics AX module navigation

AX 2012 Issue: Missing module in Dynamics AX module navigation

Issue:
An end user seemed to be missing the entire Accounts Receivable module (Figure 1 below) in AX 2012.

Thought process:
My first thought was that the issue was security: if the user doesn't have permissions to any of the menu items under that module, the module won't show up. The issue is that the user was a power user and should obviously have access to almost all objects under AR. 

The giveaway:
A key indicator that the issue was specific to a single user; other users with the same role were able to to see it. That means it must be something else outside of security.

Solution:
The solution was that the module was unintentionally hidden. Make it visible (or hide it!) by going to File > 'View' > 'Modules' > Uncheck/Check the appropriate module(s) (Figure 2 below). When they are checked, they are visible. If they are unchecked, they are not visible. Once rechecking the AR module, we can see the module is back in place (Figure 3 below)

Note: This is a great way to hide modules that users may not need. It can simplify the modules list for end users who really only need to see specific things. For example, a retail power user may need to see customers, workers, etc. Since those example objects also exist in the AR, sales and marketing, and HR, the user will see the AR, Sales&Marketing, HR, and Retail modules. Since the user can get to everything they need in the Retail module, they may not want to see those other three modules. By hiding the other modules on a user by user basis, it will simplify their view of the system and seem less cluttered. 

Figure 1 - Missing Accounts Receivable module in AX 2012 navigation

Figure 2 - The accounts receivable module is unchecked, meaning that it is hidden.

Figure 3 - The Accounts Receivable module is now visible to the user

Tuesday, 26 April 2016

Creating Custom Workflow from scratch in Dynamics Ax 2012

 Suppose we are working in HR module and client wants that worker will add their expense and send for Approval.

For this requirement, first we create a custom table and create its relation with Worker table. And then develop a custom workflow on it.
So this post contains tasks
  • Table creation and relation with worker
  • Create a simple entry form and list page.
  • Workflow



So first we create a new table and generate its relation with Worker ID.

If we open HCMworker table we will find that its primary key is “PersonnelNumber”.

We add new enum type which has expected values, medical, Certification, Food expense and others. We use Tst as extension for our example’s artifacts.
Expense

Now create a new table set its Name as tstWorkerExpenseTable.
Expand table node and right click on relation node. Create a new and set table as HCMWorker.

Rightlick on it new => foreignKey=>Primarykey.
HcmWorker
You will find new and new field added, you can rename it, if you check the properties you will the  which will int64 bit.

Now drag and drop enum created in previous step
Rename it to Expense type.


Now add one more field name It Amount of real type and set its label as Amount
Save It. Also create a field group with overview and drag all fields in that group.
Table final structure will be as follow.
Table Final stage


Form create simple form with Name tstWorkerExpense and set its data source as
Now create a simple form and set its datasource as TstWorkerExpense. And set data source properties  “Edit” and “insert if empty” to no.

Add grid on form and drag and drop fields from data source to grid. Save it.  Form structure will be look like.
WorkerListPage

Run the form you will find something like. You can improve from. It is enough for our current example
Also insert command buttons on action table for new, Edit and delete.
CreateForm


You can improve but for current example it is enough.

Now create a new enum  for which will used as approval status for table.
WorkFlowStatus
Drag and drop in fields of tstWorkerExpense. Save table, compile and synchronize, so this will be reflect at SQL Server level.

Now Its time to write some code that will work for state change in workflow steps.
Right click on Method node on tstWorkerExpense and click on CanSubmitToWorkFlow
CanWorkflow




Update it as follow.

publicboolean canSubmitToWorkflow(str _workflowType = ”)
{
boolean ret;

if (this.ExpenseStatus ==tstExpenseStatus::NotSubmit)
{

ret = boolean::true;
}
else
{
ret =boolean::false;
}

return ret;
}

New add a new static method with Name “updateworkFlow” and update it as follow

publicstaticvoid updateWorkFlowState(RefRecId _id, tstExpenseStatus _status)
{
tstWorkerExpense _Expense;

selectforUpdate _Expense where _Expense.RecId ==_id;
if (_Expense !=null)
{
ttsBegin;
_Expense.ExpenseStatus = _status;
_Expense.update();
ttsCommit;
}
}

 

Now create a Query and This query will later used when we build Workflow type on it.
Query
Add TstWorkerExpense table in it and set field  dynamic to yes.

WorkflowQuery
Now expand AOT and expand workflow right click on new Workflow Category
Custom Cateogry
Set its name tstWorkFlowCategory and set Module as HumanResource.
CategoryDetail
Save it. Now add a new me display menu Item With name “tstExpenseTable” and set its form tstWorkerExpenseTable.
Menu Item



Now expand workflow and then expand workflow Type right click and run the wizard.
WorkFlowType Wizard
Wizard1


From next window set following properties all based on artifacts we create in pervious steps.
ExpenseWizard
Ie.  Query, workflow category and menu item.  AS we test this workflow only on Ax client so check on rich client
TypeWizardFinished
Click on next.


In result a new Ax Project is created
TypeProject
  • Workflow Type
  • Classes
    • Document class which extends WorkflowDocument.
    • EventHandler class which gives implementation to handle different workflow events.
    • SubmitManager class.
  • Action menu items:
    • SubmitMenuItem pointing to SubmitManager class.
    • CancelMenuItem pointing to WorkflowCancelManager class.


Now expand the form (We created this in one above step) and expand its design, and set following properties  to it will workflow enable
WorkflowEnabled =yes
WorkflowDataSorce =tstWorkFlowExpense
WorkflowType = tstWorkerEpense (We created this in pervious step).
WorkFlowSettings

Now expand submit manager class in workflow type project and update logic as follow.
And Create a new method with following logic.

public void submit(Args _args)
{
tstWorkerExpense        workerExpense;
WorkflowComment         note = “”;
WorkflowSubmitDialog    workflowSubmitDialog;

//Opens the submit to workflow dialog.
workflowSubmitDialog = WorkflowSubmitDialog::construct(
_args.caller().getActiveWorkflowConfiguration());
workflowSubmitDialog.run();

if (workflowSubmitDialog.parmIsClosedOK())
{
workerExpense = _args.record();
// Get comments from the submit to workflow dialog.
note = workflowSubmitDialog.parmWorkflowComment();

try
{
ttsbegin;
workerExpense.ExpenseStatus  = tstExpenseStatus::Submit;
ttscommit;

// Send an Infolog message.
info(“Submitted to workflow.”);
}
catch (Exception::Error)
{
error(“Error on workflow activation.”);
}
}

_args.caller().updateWorkFlowControls();
}

public static void main(Args args)
{
tstWorkerExpenseSubmitManager submitManager = new tstWorkerExpenseSubmitManager();
submitManager.submit(args);

}

Now Create a we create workflow approval.
Expand Workflow node in AOT and then again expand Workflow approval.
Approval


Now you have to use the following artifacts we created in previous steps.

Document, which we created through workflow type wizard and tables field group. And
ApprovalWithDocument


Again new project created.
New Approval Project is created

Now expand TsWorkerExpenseAppEventHandler and update following methods.
public void returned(WorkflowElementEventArgs _workflowElementEventArgs)
{
tstWorkerExpense::updateWorkFlowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), tstExpenseStatus::ChangeRequest);
}


public void changeRequested(WorkflowElementEventArgs _workflowElementEventArgs)
{
tstWorkerExpense::updateWorkFlowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), tstExpenseStatus::ChangeRequest);
}

public void denied(WorkflowElementEventArgs _workflowElementEventArgs)
{
tstWorkerExpense::updateWorkFlowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), tstExpenseStatus::Reject);
}


public void completed(WorkflowElementEventArgs _workflowElementEventArgs)
{
tstWorkerExpense::updateWorkFlowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), tstExpenseStatus::Approve);
}

public void canceled(WorkflowElementEventArgs _workflowElementEventArgs)
{
tstWorkerExpense::updateWorkFlowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), tstExpenseStatus::Cancel);
}

public void started(WorkflowElementEventArgs _workflowElementEventArgs)
{
tstWorkerExpense::updateWorkFlowState(_workflowElementEventArgs.parmWorkflowContext().parmRecId(), tstExpenseStatus::Submit);
}


Now expand the workflow and in sub node Supported Elements, drag and drop approval artifact.
Support



Drag
WorkFlowElement



Now create a new menu item and set its form and set its following properties.
WorkFlowMenuItem
  • Form WorkflowTableListPage
  • EnumTypeParameter to ModuleAxapta
  • EnumParameter to Basic.


Now generate increment CIL. It is necessary step.


Click on this and open the workflow design.


Navigate to the menu item to open WorkflowTableListPage to design the workflow.
Click on new button.
WorkFlowScreen

Drag and drop approval on designer screen and. Link the start to shape and from shape to end .

WorkFlow
 

Monday, 18 April 2016

Deploy the Standard SQL Cubes for Instant Business Intelligence

Deploy the Standard Cubes for Instant Business Intelligence



Dynamics AX 2012 comes pre-configured with 16 reporting cubes that distills the data into a more user friendly view.  You can use these to create your own reports and dashboards from, and because they remove the need to be a database expert in order to understand the data, the general users are able to take advantage of them as well.
You may think that the creation of the cubes would be an arduous task, involving a lot of design & planning, and would require weeks or even months to get them up and running, but it’s not the case.  All you have to do is run a simple deployment wizard and you should be up and running within minutes.
What are you waiting for?
HOW TO DO IT

From the File menu, select the Tools submenu, and then the Business Intelligence (BI) toolssubmenu, and select the SQL Server Analysis Services project wizard menu item.
20131111.1
This will start up the Analysis Services project wizard. When the welcome dialog is displayed click on the Next button.
20131111.2
Select the Deploy option to create a the 16 cubes from the existing project that is already built within Dynamics AX and click the Next button.
20131111.3
Then select the Dynamics AX product from the drop down list and click the Next button to continue.
20131111.4
When the Deployment options are displayed, select the data partition that you want to create the cubes for and then click the Next button.
Note: You may only have one partition.,
Also, check the Process the project after it is successfully deployed checkbox.  This will process the data so that you will be able to report off it right away.
20131111.5
The wizard will then start running, and will probably run for a couple of minutes as the cube is being created and processed.  When it is completed, just click the Next button.
20131111.6
Now you can exit the wizard by clicking on the Finish button.
20131111.7
If you look at the Analysis Services cubes within SQL Server Management Studio, you will be able to see all of the cubes that the wizard just created.
20131111.8
If you also connect them to PowerView then you will be able to create dashboards directly from the data within seconds.
20131111.9
How easy is that!

Workflow Stopped (error): X++ Exception: Work item could not be created. Insufficient rights for user in ax 2012

Workflow Stopped (error): X++ Exception: Work item could not be created. Insufficient rights for user ?

I've had this problem a number of times and the error message doesn't give you enough information to know exactly what permissions need to be added for the user.

There are a couple of ways to determine the menu items and web menu items associated with the workflow.

The first way is to go to the AOT and look under the Workflow > Approvals node

The required display menu and web display menu items are highlighted below

The required action and web action menus are highlighted below

Check that the user has permission to access these display and action menu and webmenu items.

You can also use the Visual Studio 2010 debugger on theSysWorkflowDocument.assertAsUser() class method to locate the menu item(s) that the user doesn't have access to.

Install and configure Analysis Services for Dynamics AX 2012 R3

Install and configure Analysis Services for Dynamics AX 2012 R3

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)