• Skip to main content
  • Skip to primary sidebar
  • Home
  • About
  • Recommended Readings
    • 2022 Book Reading
    • 2023 Recommended Readings
    • Book Reading 2024
    • Book Reading 2025
  • Supply Chain Management Guide
  • PKM
  • Microsoft Excel

Ali Raza Zaidi

A practitioner’s musings on Dynamics 365 Finance and Operations

Dynamic AX 2012

No such host is known and AOS not reached SSRS Dynamics AX R3.

July 14, 2016 by alirazazaidi

Yesterday I deployed the new SSRS customization to staging, so QA / Functional guy can test.

Client configured the AOS to Database server and Application server was moved for backup services.

Due to change in AOS server I have to face two issues.

“No Such Host is known.”

2016-07-12_9-33-00

Whenever we run the report on staging server during report processing Error pop up appear with message “ Host not found “.

 

Modification in Windows Register, did not solve this problem. I have to reinstall the Reporting services extension form Dynamics Ax 2012 R3.

Reporting Server Extension

 

 

Second issue I faced that During installation of Reporting Extensions. Setup did complete and shows message about it did not locate the Required AOS. Interesting setup pointing to old server.

AoS problem

 

I solve this error by removing the credential save for Business connecter form Administration module for Dynamics AX. After rerun the reporting extension form AX Setup, Installation will complete successfully. Later deploy all reports and reports runs successfully.

 

‘Invalid enum value ‘GMTPLUS0500ISLAMABAD_KARACHI’ cannot be deserialized into type Dynamics Ax 2012 R3 WorkFlow Error.

May 14, 2016 by alirazazaidi

Couple of months ago, I have to face a strange error and its very strange solution. So I decide to share it and document so it helps others as well as I remember if I face it again.

Error occur when we try to create, edit or delete workflow. This error is certainly because of time zone. And As we are in Pakistan so certainly the Legal entity have to use local time zone.

But interestingly Workflow works fine in all other legal entity with same time zone. So what is problem with certain legal entity.

Short detail of error is as follow

‘Invalid enum value ‘GMTPLUS0500ISLAMABAD_KARACHI’ cannot be deserialized into type ‘Microsoft.Dynamics.AX.Framework.Workflow.Model.AxWorkflowServiceReference.Timezone

 

 

This error  occurs when following statement execute.

    workflowConfiguration = Microsoft.Dynamics.AX.Framework.Workflow.Model.WorkflowModel::

Create(templateName, curext(), curUserId(), domainUser);

As per my understanding we cannot debug framework classes. So We cannot get understand what cause problem.

 

After efforts, I found that this error is caused by time zone set in legal entity’s primary Address instead of legal entity’ own time zone.  I changed it to Central time zone US and Canada, Everything starts to working fine.  I am surprised, what logic required to create Workflow based on Primary Address time zone.

image010

 

 

 

 

 

The detail error message is looked like

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.ServiceModel.Dispatcher.NetDispatcherFaultException: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org:response. The InnerException message was ‘Invalid enum value ‘GMTPLUS0500ISLAMABAD_KARACHI’ cannot be deserialized into type ‘Microsoft.Dynamics.AX.Framework.Workflow.Model.AxWorkflowServiceReference.Timezone’. Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.’.  Please see InnerException for more details. —> System.Runtime.Serialization.SerializationException: Invalid enum value ‘GMTPLUS0500ISLAMABAD_KARACHI’ cannot be deserialized into type ‘Microsoft.Dynamics.AX.Framework.Workflow.Model.AxWorkflowServiceReference.Timezone’. Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.

 

If we see description that problem is conversion between two time Zone. On comparison

I found time zone enum  “Microsoft.Dynamics.AX.Framework.WorkFlow.Model.AXWorkflowServiceReference.TimeZone” did not have GMTPLUS0500ISLAMABAD_KARACHI.

2016-04-15_11-39-18

2016-04-15_11-40-27

 

 

 

Unit Conversion Real world scenario, Dynamics Ax 2012 X++

April 26, 2016 by alirazazaidi

A few days ago, I got requirement, where I have to sum up the total quantity and amount of all Purchase line. Here we assume that All lines in Purchase order belongs to same set or convertible unit.

You can set these unit conversion settings at

Organization administration > Setup > Units > Unit conversions.

 

 

 

Public void SumQTYAndAmount(PurchTable  PurchTable)

{

PurchLine               line;

 

 

UnitOfMeasureSymbol     toSymbol ="Ranjah";

UnitOfMeasureSymbol     fromSymbol;

Qty                     SumQty=0;

AmountCur AmountPurch=0;

UnitOfMeasureRecId      fromRecid,toRecid;

;

 

 

 

select * from plan where plan.PurchTable == PurchTable.PurchId;

 

//  select sum(LineAmount), sum(QtyOrdered) from line where line.PurchId == PurchTable.PurchId;

while  select * from LineQty where LineQty.PurchId == PurchTable.PurchId

{

if ( LineQty.PurchUnit ==toSymbol)

{

SumQty +=LineQty.QtyOrdered;

amountQty+=LineQty.LineAmount;

}

else

{

fromSymbol = LineQty.PurchUnit;

toRecid =UnitOfMeasure::findBySymbol(toSymbol).RecId;

fromRecid =UnitOfMeasure::findBySymbol(fromSymbol).RecId;

landQty += UnitOfMeasureConverter::convert(landQty,fromRecid,toRecid,NoYes::Yes);

amountQty+=LineQty.LineAmount;

 

}

 

}

}

How to get next recid in TSQL Dynamics Ax 2012

February 5, 2016 by alirazazaidi

Suppose we have to insert data into VendGroup table through TSQL, this scenario usually appear when integration or data migration team inject data into AX using TSQL without using AIF.

There are two tables are important SQLDICTONARY and SYSTEMSEQUENCES.

 

SQLDictonary table contains the table id for example Vendtable has 490 id.

SYSTEMSEQUENCES table contains the sequence number in nextVal field.

 

I used following code snippet which helps me to insert into AX through TSQL.

declare @tableId as int = (select tableid from SQLDICTIONARY where name like 'VendGroup' and FIELDID=0);
print @tableId;
declare @recId as bigint =(select nextval from SYSTEMSEQUENCES where TABID=@tableId and name='seqno');
print @recId;
select @recId set @recId =@recId + 1;
print @recId;
insert into DBO.VENDGROUP ([VENDGROUP],[NAME],[RECID],DATAAREAID,CREATEDBY,DEL_CREATEDTIME,CLEARINGPERIOD,PAYMTERMID,RECVERSION) values ('80','TSQLTest',@recId,'usmf','ALICIA',19372,'Net10','Net10',0 );
update SYSTEMSEQUENCES set NEXTVAL = @recId where TABID=@tableId and name='seqno';

ssss
reference:

Delete a legal entity in Dynamics Ax 2012

December 12, 2015 by alirazazaidi

Today I have to delete all legal entities from one of MS Dynamics Ax 2012 environment.

During this I got following error while deleting legal entities.

“Can not record , The corresponding AOS  validation failed”.

This error clearly shows that Transnational data exists in that legal entity.

I follow these steps to clear all legal entities.

  • First of open AOT with development rights.
  • Change the legal entity from DAT to required legal entity.
  • From AOT, expand the Class node, type SysdatabaseTransDelete. When find, right click on it click it open / run. It will delete all transactional history of required legal entity.
  • Now open the new workspace and open Organization Administrator ion => setup=>organization => legal entities.
  • Select on required legal entity and click on delete from top menu.

Some but on some legal entities delete button is still disabled. Because there is no important data as well I want to delete all legal entities, I manually delete the data in RCHYRELATIONSHIP table.

Otherwise I have to delete the organization hierarchy data carefully.

 

 

Following two links help me to solve this issue.

http://daxture.blogspot.com/2014/09/delete-legal-entities-in-ax-2012.html

https://community.dynamics.com/ax/f/33/t/139605

How to handle empty pages in SSRS report dynamics Ax 2012

November 30, 2015 by alirazazaidi

Today I was facing the report issue that it print three blank pages other than one require page. This issue is due to page body is covering more area then print page size. During development phase we test the print page size by saving the report review as pdf. Followings is the tip which helps me to remove empty white pages from report print.

Check that page size and set it also set the you want print in portrait or landscape.

For example if I have to run the report on A4 and portrait form. Then I will perform following steps to set the print page setting and size of report page.

Right click on gray area of report and click on report properties.

2015-11-30_22-44-15

 

And set the report print and size and also set left and right margins

Page Size

 

 

 

Now note the page size is 8.27. We have to check report body size and it must be less than 8.27 inch. For this right click on White area in report canvas and press f4.

Body Size detail

 

 

From property window you can check it body size. If it larger then 8.27 in, then you must reset the table, tablix and matrix to and resize the body to less then 8.27.

resize

 

 

Now check rerun the report and save its preview in pdf.

 

 

Invent Journal and its relation with Voucher sequence number Dynamics Ax 2012 R3

November 18, 2015 by alirazazaidi

 

X++ code for these Invent transfer and movement journal is available in different blogs and website. The voucher number for these entries is little bit tricky. This Voucher Number is set InventJournalName as fellow screen.

xyz

By writing this simple tip I used out of demo vm with contoso data.

So If expand the InventJounralName table we will find this voucher sequence number set in VoucherSequenceNumberTable field.

VoucherSequenceNumber

If we expand the Relation node of InventJournalName table we find its relationship with Sequence Number table based on RecId.

ReleationShip

For getting next voucher Number for Journal lines we have to use static method of NumberSeq  as

 

 

InventJournalName   inventJournalName;

NumberSeq     _sequence;

num _voucher;

select firstOnly inventJournalName

where inventJournalName.JournalType == InventJournalType::Any

ttsBegin;

_sequence=   NumberSeq::newGetNumFromId(   inventJournalName.VoucherNumberSequenceTable);

_voucher=_sequence.num();

ttsCommit;

Required date must not be before today’s date Validation Dynamics Ax 2012

November 12, 2015 by alirazazaidi

Today I got very small task to remove date validation. This validation appear in out of the box and did not let create functionality for previous dates. Surprisingly I did not find any validation code in form. Later I discover that at table level  validation logic was written in function “validateField(FieldId _fieldIdToCheck)”.

Custom Workflow from scratch, Dynamics Ax 2012

October 21, 2015 by alirazazaidi

Let start work on fake requirement. 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 previous 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)

{

CustTable                           CustTable;
   CustAprWorkflowTypeSubmitManager    submitManger;   
   recId _recId =                      _args.record().RecId;
   WorkflowCorrelationId               _workflowCorrelationId;


   workflowTypeName                    _workflowTypeName = workFlowTypeStr(“CustAprWorkflowType”);
   WorkflowComment                     note = “”;
   WorkflowSubmitDialog                workflowSubmitDialog;
   submitManger =                      new CustAprWorkflowTypeSubmitManager();
   
   
   


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


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


       try
       {
           ttsbegin;
           // Activate the workflow.
           _workflowCorrelationId = Workflow::activateFromWorkflowType(_workflowTypeName, CustTable.RecId, note, NoYes::No);


           CustTable.WorkflowApprovalStatus = CustWFApprovalStatus::Submitted;
           CustTable.update();
           ttscommit;


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


   _args.caller().updateWorkFlowControls();

}

 

 

 

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

 

 

 

 

 

Current user and its employee Name and department

October 19, 2015 by alirazazaidi

Today I got small requirement where I have to pick and display current log in user Name, Following code snippet helps me

static void curUserInfo(Args _arg)
{
    str sUserId;
Name  name;
str departmentName
;

    ;
    sUserId = curUserId();
    info( "Current user ID is " + sUserId );
name= HcmWorker::find(DirPersonuser::findUserWorkerReference(sUserId)).name();
 departmentName=    HcmWorker::find(DirPersonuser::findUserWorkerReference(sUserId)).primaryDepartmentName();
info ("Name is " + name);

}
« Previous Page
Next Page »

Primary Sidebar

About

I am Dynamics AX/365 Finance and Operations consultant with years of implementation experience. I has helped several businesses implement and succeed with Dynamics AX/365 Finance and Operations. The goal of this website is to share insights, tips, and tricks to help end users and IT professionals.

Legal

Content published on this website are opinions, insights, tips, and tricks we have gained from years of Dynamics consulting and may not represent the opinions or views of any current or past employer. Any changes to an ERP system should be thoroughly tested before implementation.

Categories

  • Accounts Payable (2)
  • Advance Warehouse (2)
  • Asset Management (3)
  • Azure Functions (1)
  • Books (6)
  • Certification Guide (3)
  • Customization Tips for D365 for Finance and Operations (62)
  • D365OF (59)
  • Data Management (1)
  • database restore (1)
  • Dynamics 365 (58)
  • Dynamics 365 for finance and operations (135)
  • Dynamics 365 for Operations (165)
  • Dynamics AX (AX 7) (134)
  • Dynamics AX 2012 (274)
  • Dynamics Ax 2012 Forms (13)
  • Dynamics Ax 2012 functional side (16)
  • Dynamics Ax 2012 Reporting SSRS Reports. (31)
  • Dynamics Ax 2012 Technical Side (52)
  • Dynamics Ax 7 (65)
  • Exam MB-330: Microsoft Dynamics 365 Supply Chain Management (7)
  • Excel Addin (1)
  • Favorites (12)
  • Financial Modules (6)
  • Functional (8)
  • Implementations (1)
  • Lifecycle Services (1)
  • Logseq (4)
  • Management Reporter (1)
  • Microsoft Excel (4)
  • MS Dynamics Ax 7 (64)
  • MVP summit (1)
  • MVP summit 2016 (1)
  • New Dynamics Ax (19)
  • Non Defined (9)
  • Note taking Apps (2)
  • Obsidian (3)
  • Personal Knowledge Management (2)
  • PKM (13)
  • Power Platform (6)
  • Procurement (5)
  • procurement and sourcing (5)
  • Product Information Management (4)
  • Product Management (6)
  • Production Control D365 for Finance and Operations (10)
  • Sale Order Process (10)
  • Sale Order Processing (9)
  • Sales and Distribution (5)
  • Soft Skill (1)
  • Supply Chain Management D365 F&O (3)
  • Tips and tricks (278)
  • Uncategorized (165)
  • Upgrade (1)
  • Web Cast (7)
  • White papers (4)
  • X++ (7)

Copyright © 2025 · Magazine Pro On Genesis Framework · WordPress · Log in