Search This Blog

Friday 1 December 2017

Getting Dimension Values from Financial Dimensions in Dynamics 365 For Operations

I got one tasks of report development in which I have to show the Financal Dimension and its Dimension Value in a lookup on report parameter.

To do this the one I have to grab all the Dimension Values against the Financial Dimension to show in a lookup.

Below is the navigation for Financial Dimension Form in D365:

General Ledger -> Chart of Accounts -> Dimension -> Financial Dimensions.


















The form for Financial Dimension is.











As you can see in the above image there is a dimension value button when you click on it a new form will open containing all of the dimensions against that selected Financial Dimension.














So the question is how can we get the Dimension Values based Financial Dimension by using query.

Below is the code for you:

class RunnableClass1
{       
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {   
        DimensionAttribute              dimAttr;
        DimensionAttributeViewContract  dimAttrViewContract;
        Query                           q;
        QueryRun                        qR;
        QueryBuildDataSource            qbds;
        Common                          common;

        dimAttr = DimensionAttribute::findByName("Department");


        dimAttrViewContract =  DimensionAttribute::getViewContract(dimAttr.RecId);

        q = new Query();

        changecompany (dimAttr.company())
        {
            qbds = q.addDataSource(dimAttrViewContract.parmViewId());
            qbds.addSortField(dimAttrViewContract.parmValueFieldId(),SortOrder::Ascending);

            // Apply ranges on language ID fields.
            DimensionAttribute::addTranslViewRangesToBackingEntityQuery(dimAttr.RecId, qbds);

            if (DimensionCache::instance().dimensionAttributeHasCategorization(dimAttr.RecId))
            {
                if (dimAttr.Type == DimensionAttributeType::MainAccount)
                {
                    qbds.addRange(dimAttrViewContract.parmCategoryFieldId()).value(queryValue(LedgerChartOfAccounts::current()));
                }
                else if (dimAttr.Type == DimensionAttributeType::CustomList)
                {
                    qbds = qbds.addDataSource(tablenum(DimensionAttributeDirCategory), 'DimAttDirCat');
                    qbds.relations(true);
                    qbds.joinMode(JoinMode::InnerJoin);
                    qbds.fetchMode(QueryFetchMode::One2One);
                    qbds.addLink(dimAttrViewContract.parmCategoryFieldId(), fieldnum(DimensionAttributeDirCategory, DirCategory));
                    qbds.addRange(fieldnum(DimensionAttributeDirCategory, DimensionAttribute)).value(strfmt('%1', dimAttr.RecId));
                }
            }
        }

        qR = new QueryRun(q);
        while(qR.next())
        {
            common = qR.get(dimAttrViewContract.parmViewId());

            info(strFmt("%1 %2",common.getFieldValue(dimAttrViewContract.parmValueFieldName()), common.getFieldValue(dimAttrViewContract.parmNameFieldName())));
        }
    }

}

For more Details Below is the link:

https://community.dynamics.com/ax/b/hellodax/archive/2015/07/07/get-all-financial-dimension-value-and-description-from-dimensionattribute

Thanks,
Zahid

Thursday 30 November 2017

Open Table Browser in other than Dat Company in Dynamics 365 for Operations

Some time we want to open the table browser in other than DAT company in Dynamics 365 for operations.

To open table browser in other company below is the link that contains the full description:

https://community.dynamics.com/crm/b/microsoftdynamicscrmsolutions/archive/2016/01/25/open-table-browser-with-different-legal-entity-in-ax-7


Thanks,
Zahid. 

Wednesday 27 September 2017

Resolved: The field with ID '21' does not exist in table 'smmContactPersonEntityCopy'.

One day one of my Integration Teams was trying to insert records from CRM to Dynamics 365 for Operations using the integration tool i,e Logic apps.

There logic app was configured correctly and they were successfully able to fetch the records from CRM but when they were trying to insert the records in D365 for operations they were getting the following error:

 "An error has occurred.  Error executing code: The field with ID '21' does not exist in table 'smmContactPersonEntityCopy'.\r\nclientRequestId: 4f0ca82f-ff64-46a9-9066-ff62cea0b036" 

I investigated the issue in D365 for operations.Actually they copied the standard AX entity i,e ContactPersonEntity to create the new one smmContactPersonEntityCopy.

I created the job with in D365 for operations to insert the records into the same entity.















After running the above job I was also getting the same error that I have stated above.After some  debugging I found out that the error was on the init value method of my entity i.e

smmContactPersonEntityCopy.initValue();

 When I looked into that method and found out that it was throwing exception on number sequence generation.








After some analysis I found out that the other developer has copy the standard AX entity i.e smmContactPersonEntity and created new Entity with ame smmContactPersonEntityCopy and he forgot to update the refrences in code.

So as you can see in the above image Its smmContactPersonEntity I have change this to smmContactPersonEntityCopy and after that I rebuild the project and I run my job which was successfully able to insert the records in that entity and my logic app was also working fine.

Below is the updated code:





Thanks
Zahid.

Wednesday 24 May 2017

Development Approach in Dynamics 365 For Operations

The are two ways of development approach in D365 one is Extension Development Approach and Overlayering development approch.

  1. Extension Development Approach.
  2. Overlayerring Development Approach.

Extension Development Approach:

This Approach is use if you want to create new objects or you don’t want to customize the existing standard AX functionality given by Microsoft.

In extension development approach you can enable or disable the controls of standard ax objects and you can do what you want with the new objects that you have created.

Benefit of using the Extension Development approach is  that It would be easier for you to do the future upgrades but sometimes we might need to customize the existing standard AX object based on our requirement. in this  case we use Over layering development Approach.

To do the extension development you first need to create the model and under that model add new objects or refer to the existing objects to enable and disable some of their controls.

Below are the steps for working in extension development approach.

Open Visual Studio Click Dynamics 365 -> model management ->  Create Model










A new wizard will open where you give name and other details of the model.



















Now click next.



















In the above screen you have the option to use the extension development approach or the over layering development approach.

If you choose the 'Create new package' option than it will be the extension development approach.

And if you choose the 'Select existing package' than you have to select the existing model which you will be customizing that would be the over layering development approach.

If you select 'Create new Package' and then click next than you have the option to select the existing package if you want to use objects of that model. (note: you can only enable or disable control of existing AX objects but you cannot customize it)
Like this.



















When you click next final screen will appear where you can check the checkbox Create new project so once you click next a new dialog will appear when u can create new project or u can uncheck the checkbox model will created and then you can create the project manually.










After creating the model In the above image I right click the standard AX form i.e cust table.

Now I have the option of either customize it or create extension. As you can see on the right pane I have use this form as customize and extension both (just for example).

It is because my module is over layering development approach. If my module would be total new I,e extension development approach then I won't be able to customize that form I extend that form.

Now I will show you the properties of the form that I have customize in which I have full authority to change any property.









and below is the properties of the same form which I extended.in which I can change only some properties not all of them.









Feel free to comment if you have any questions.

Thanks,
Muhammad Zahid.

Monday 10 April 2017

Create Export File Format For Method of Payment in AX 2009

This Blog is related to the Receipt Journal Payment Generation Process.

So Basically on the Account Receivable form when you created the new Journal like this.



















Navigation Account Receivable -> Journals -> Payments -> Receipt Journal.

after that once you click the lines a new form will open where you create the payment proposal.












After that you click on the functions -> generate payments button a new dialog will open where you select the method of payment radio button or the export file format radio button like this.




















if you select the method of payment than the file format that you have define in method of payment setup form will be use to generating the file.

Go to Account Receivable -> Setup ->  Payment -> methods of payment.













you can also click setup button to select any other File Format.

Now the scenario is there is requirement that you need your custom define method of payment for example creating sales orders in csv file format while generating the payment as i show in above images.

So what you have to do is create two classes like this:

CustOutPaymRecord_YourClass inherit this class from CustOutPaymRecord

CustOutPaym_GlobalInt inherit this class from CustOutPaym

The CustOutPaymRecord_YourClass  must contains the output method.In that method you will right the logic to get the sales orders and write them in the csv file.like this.

















Other than that you can also override the checkValues method if you want to validate any thing in the LedgerJournalTrans table basically this method is calls before the output method from standard AX classes.

You will also have to override the interfaceName() method in your CustOutPaym_yourClassName class to give the name of your Export Format like this:











Basically the text that you define in that method will be shown as export file format on the dialog while generating the payment or on the setup form when you select the export file format.

Other methods that you need override are:


























above method is use for taking file format as an input.






























You can also check the existing standard Ax classes that contains the file format method like above.

Name of the class will same as i have mentioned above like this:

CustOutPaymRecord_YourClass inherit this class from CustOutPaymRecord

CustOutPaym_GlobalInt inherit this class from CustOutPaym

Let me know if you have any questions.

Thanks,
Muhammad Zahid.


Monday 13 March 2017

Payment Schedule In Dynamics 365 For Operations


Payment Schedule:

Payment Schedule is basically used to give the payment to vendor in particular installments.

For example I want to give the payment in sixth month of installments with fixed amount.

Go to: Accounts Payable -> Payment Setup -> Payment Schedule.















Here Fixed Quantity in allocation means fixed amount of installments.(you can explore the other options as well in that drop down).

Payment per means either you want to give the installments on daily basis or monthly or yearly.

Number of payments means you have to define number of installments. (this option will be enable if you select the fixed quantity option in the allocation drop down).

maximum amount and minimum amount means the maximum or minimum amount required to qualify to apply this payment schedule.

Sales tax and charge allocation means: giving the option to pay sales tax and charges either in first transaction or last transaction or proportionally in installments.

Now I will show you how we can use this payment journal in our payment schedule.

Goto: Accounts Payable -> Payments -> Payment Journal










Now select the payment journal and click lines in the action pain as you can see in the below image.









A new form will open where u can see the lines:








now select the transaction and than click on the settlement button as you can see in the above image.A new screen will open where u can see the un settled transactions like this.














No mark the transaction on which u want to apply the payment schedule and click on apply payment schedule as you can see in above image.

Now once you click the apply payment schedule a new window will open where you can apply the payment schedule.There two options you can manually create and apply the payment schedule based on amount and percentage or you can select the already created payment schedules.













Now once u click the payment schedule button it will ask you about the payment schedule that you want to apply like this.













Now when i select the payment schedule and click it divides the amount in six month equal installments.You can also divide the amount in percentage basis as well.













As you can see in the above image my amount is divided in six equal installments based on amount.
If you select percentage from the drop down than amount will be divide based on percentage not based on amount.

Now when i click OK button it will divide the transaction in six equal transactions with due date and under the same invoice as you can see in the below image.













As you can see in the above image payment amount is divided in six equal installments with the due date and same invoice number.

This was all related to creating and applying the Payment Schedule in Microsoft Dynamics 365 for Operations.

Thanks,
Muhammad Zahid

Thursday 16 February 2017

Field Fixed Relation and Related Field Fixed Relation In Microsoft Dynamics AX

Field Fixed Relation and Related Field Fixed Relations are not commonly used in AX but its Good to understand there concept as in some scenarios they are very useful.

Below are the two links that explains both Field Fixed Relation and Related Field Fixed Relation in Microsoft Dynamics AX.

https://amazingax.wordpress.com/2013/04/15/microsoft-dynamics-ax-2012-understanding-related-field-and-fixed-field-relation-on-ax-tables/

https://msdn.microsoft.com/en-us/library/bb190115.aspx?ranMID=24542&ranEAID=TnL5HPStwNw&ranSiteID=TnL5HPStwNw-CzrYWf0.SeiooLURSsjHrQ&tduid=(7765185542a4606ade00d00d5716e203)(256380)(2459594)(TnL5HPStwNw-CzrYWf0.SeiooLURSsjHrQ)()


Let me know if you have any questions related to this.

Thanks,
Muhammad Zahid.