Tuesday, January 22, 2019

Microsoft Dynamics Stopped (error): SysWorkflowQueue-resume X++ Exception: D365FO / AX2012

After submitting the Workflow for workflow you may encounter these errors. These can be caused both from technical and configuration reasons. 


Stopped (error): SysWorkflowQueue-resume X++ Exception: Work item could not be created. Insufficient rights for user *.
at SysWorkflowWorkItem-create
SysWorkflowWorkItem-createWorkItems
SysWorkflow-save
SysWorkflowQueue-resume



Stopped (error): SysWorkflowQueue-resume X++ Exception:  Token StartElement in state Epilog would result in an invalid XML document.
 at SysWorkflowEvaluationProvider-evaluateCondition
SysWorkflowEvaluationProvider-evaluate
SysWorkflowQueue-resume

AX Functional consultants can do following steps to solve it:


  1. Open AOT> Workflow> Workflow types>*YourWorkflowType* 
  2. In the properties window there will be 'DocumentWebMenuItem' and 'DocumentMenuItem' add these menuitems privileges to user role who is executing the workflow. If these menuitems are not part of any privilege ask the developer to create one and then assign.
  3. If it still does not solve the issue ask technical consultant to solve this issue.

AX Technical consultants can do following steps to solve it:

  1. Make sure the privilege of Document menu items is created.
  2. Open your Workflow query make sure the following:
    1. You have followed the parent child relationship for example if in case of SalesTable and SalesLine the SalesLine should be child node of SalesTable. SalesLine should not be in same hierarchy as SalesTable or hierarchy above it.
    2. There should NOT be any inner join in your query- very common mistake. Change all inner joins to outer join.
    3. Make sure you have made the correct relationship conditions of parent and child.
  3. After these changes make sure you Rebuild the project with Sync and reset IIS in case of D365FO and run incremental CIL and sync element in case of AX 2012.
  4. Create a new record to test if changes have been reflected.

Have a good day.

Monday, January 21, 2019

Microsoft Flow increment local variable

Microsoft flow has made it easy to loop through records, but you have to keep the loop count by yourself in case you need to do manipulation based on counter. Here is how to do it.


  1. Initialize a variable by clicking:

    1. Inset a new step the (+) sign on line
    2. Add an action
    3. In the search bar write 'initialize variable', then select Initialize variable element from list
    4. Give your variable a logical name and select the variable type from drop down. You have to give a initializing value to your variable.
  2. Increment variable:
    1. Go to the loop where you want to increment variable
    2. Add an action
    3. In the search bar write 'increment variable', then select Increment variable element from list.

    4. From the drop down select your variable, and in the value add the to be incremented by value.
  3. Use the value in your operation:
    1. Click the field where you want you use the variable
    2.  Select your variable to use

Have a good day :)


Tuesday, January 15, 2019

D365FO Table browser error: You are not authorized to login with your current credentials.

Hi,






If you can access AX from front end but cannot access table browser; there you need some configuration change. Here is how you do this:



  1. Open notepad as Administrator, from File menu click Open and navigate to
    C:\AOSService\PackagesLocalDirectory\Bin

    select the 'DynamicsDevConfig.xmlfile and click open



    In case you didn't find this DynamicsDevConfig file in Bin folder open this file from

    C:\Users\@YourName\Documents\Visual Studio 2015\Settings
  2. In the opened XML file scroll down to find the tag   <OfflineAuthenticationAdminEmail> and edit the value with your email. Save and close the file.

  3. Restart visual studio. Now you will be able to see table data in table browser.





D365FO Debugging

Follow the following steps to allow debugging in Dynamics 365 for Finance and Operations:

  1. On Visual studio go to Dynamics 365 > Options > Debugging

  2. On Visual studio go to Debug > Options > Debugging > Symbols
  3. Set your project as startup project by right clicking on project and selecting 'Set as StartUp Project'
  4. Set the element which you want to debug as startup object by right clicking on element and selecting 'Set as StartUp Object'
  5. Set a breakpoint in first line of code snippet which you want to debug.
  6. You now have two options:

    Option 1:
    • Start the project directly from Visual Studio by clicking on 'Start' button on Action pane or use shortcut F5. It will build the project and run on a new browser instance.
          Option 2:

    • Build your project (shortcut Alt+b,u)
    • On internet explorer login to your environment, in case if already logged in refresh the tab.
    • Attach 'w3wp.exe' process by clicking on Debug > Attach to process... (or use shortcut ctrl+alt+p). On the opened form check the 'Show processed from all users'  and select 'w3wp.exe' from the list and click Attach button. It will attach services need for debugging.



Your breakpoint will hit once you run your target form/class/report. :)



Monday, January 14, 2019

D365FO An error occurred during report data sets execution after adding a new dataset

Hi,


A common error in Microsoft Dynamics 365 for Finance and Operations reporting is data set execution problem. It usually occurs after adding another data set to your existing report. The problem is due to caching of previous report state in different programs. One of the following solutions will work for you:

Solution 1-  Restart report service
1.1 Open reporting server configuration



 1.2 Stop and then start the reporting service




Solution 2- Delete the cached RDL file, clear your usage data and build report again

2.1 Open the reporting server configuration

2.2 In the Web Portal URL you can see an URL click on it, it will redirect you to reporting web portal home page.

In case you are unable to click the URL click the 'Apply' button in the footer to enable the URL.



2.3 Delete the report RDL file.

2.4 Clear your usage data from AX -> Settings -> User options -> Usage data -> Reset
2.5 Build and deploy your report again.


You can now successfully run your report :)


Thursday, January 10, 2019

Dynamics AX create employee compensation (Fixed plan) through code X++

Hi,

Here is code to create employee compensation through code in Microsoft Dynamics AX. The method uses standard classes. All the variables starting with New* are parameters to create compensation.


private boolean createEmployeeFixedCompensation()
{
    boolean                                             ret = true;
    HRMCompFixedEmpl                     hRMCompFixedEmplInsert;
    HRMCompFixedPlanTable              hrmCompFixedPlanTable;
    HRMCompFixedEmplActionHire   hrmCompFixedEmplActionHire;

    try
    {

         if (NewActionId)
{
hrmCompFixedEmplActionHire = new HRMCompFixedEmplActionHire();

hRMCompFixedEmplInsert.PlanId   = NewPlanId;
hRMCompFixedEmplInsert.Worker  = NewHcmWorkerRecId;
hRMCompFixedEmplInsert.Status    = HRMCompFixedEmplStatus::Active;

hrmCompFixedPlanTable = HRMCompFixedPlanTable::find(NewPlanId);
hRMCompFixedEmplInsert.Type                   = hrmCompFixedPlanTable.Type;
hRMCompFixedEmplInsert.CurrencyCode    = hrmCompFixedPlanTable.CurrencyCode;
hRMCompFixedEmplInsert.PayFrequencyId = hrmCompFixedPlanTable.PayFrequencyId;

hRMCompFixedEmplInsert.ActionId       = NewActionId;
hRMCompFixedEmplInsert.Position        = NewHcmPosition;
hRMCompFixedEmplInsert.ValidFrom    = DateTimeUtil::date(NewEmploymentStartDate);
hRMCompFixedEmplInsert.ValidTo         = DateTimeUtil::date(NewEmploymentEndDate);
hRMCompFixedEmplInsert.PayRate        = NewPayRate;
hRMCompFixedEmplInsert.ProcessType = HRMCompProcessType::NonCyclical;

hRMCompFixedEmplInsert.doInsert();

HRMCompFixedEmplActionHire.parmHrmCompFixedEmpl(hRMCompFixedEmplInsert);
HRMCompFixedEmplActionHire.parmActionType(HRMCompFixedActionType::HireRehire);

HRMCompFixedEmplActionHire.run();

}
    }
    catch
    {
        exceptionTextFallThrough();
        ret = false;
    }
    return ret;
}


Have a good day :)

D365FO Create Workflows on existing form with Extension

You need to know:
Dynamics 365 for Finance and Operations (AX 7) allows us to extend its functionality through creating extension of elements or creating new elements. Unlike previous versions where we could easily open any OOTB element do whatever changes we wanted (i.e. Customization), D365FO stops us change its OTTB elements through its best practices rules and more extension oriented architecture.

Problem statement:
We can create workflows on both new forms and existing OOTB forms. Because authoring workflows need to modify forms and source table on which workflow is needed we cannot use extension method to enable workflows on existing forms.

Solution summary:
We will create a new table which hold the primary key/ RECID of the target form primary table and the workflow status enum only. Also we perform all workflow related business logic on that table. We then add that table on Data source of the target form which will eventually enable workflow. 
Here is the detail process:







5. Authoring workflows:
Then as usual create workflows on the just created table.



Create workflow category, Query, Type and approval elements. For my practice I created workflow on Transfer order.