Search This Blog

Thursday 25 September 2014

Remove Dynalinks Between Forms in Microsoft Dynamics AX 2012

Some times when we open the child form from another form than the datasource of the child form is sync with the previous form this is due to the dynalink between these two forms and all the data is shown on the child form.

you can use the below code on the init method of the child form after the super() to remove the dynalink between these two forms.

DataArea_DS.query().dataSourceTable(tableNum(DataArea)).clearDynalinks();
UserDataReaFilter_DS.query().dataSourceTable(tableNum(UserDataAreaFilter)).clearDynalinks();

The above two datasources are the datasources of the child form.

For info related to the dynalink you refer to the below link.

http://dynamicsuser.net/forums/p/40062/205388.aspx

Thanks

Muhammad Zahid

Select Marked Records From Grid in Dynamics AX 2012

Below is the Form in which I have selected the three records from the Grid:











Below is the code getting the selected records on the close ok method.

DataArea dataArea1;

dataArea1 = DataArea_DS.getFirst(1);
while(dataArea1.RecId != 0)
{
     info(strFmt('%1,%2',dataArea1.id,dataArea1.name));

    dataArea1 = DataArea_DS.getNext();
}

Below is the result after pressing the ok button on the form.

The records that we have selected will be printed.




















This was all related to this.

Thanks

Muhammad Zahid.

Show or Hide The CheckBoxes On Grid

To show or hide the checkboxes on grid on form you have to set the property "ShowRowLabels" of the Grid.

if the the property ShowRowLabels = yes.Than form grid will look like this:

 


















if the the property ShowRowLabels = no.Than form grid will look like this:




















Thanks

Muhammad Zahid.

Getting the DataSource of the Caller Form

I was working on scenario in which there another form is open from one form and I need to get the datasource from the caller form in my new form.

The code to get the datasource of the caller form is:

CustTable = custTable;

if(element.args().record().TableId == tablenum(CustTable))
{
    custTable = element.args().record();
}


Thanks

Muhammad Zahid.


Friday 29 August 2014

Convert Currency based on the Exchange Rates in Microsoft Dynamics AX 2012

In Microsoft Dynamics there is a method available for converting the amount from one currency to another based on the exchange rates.

The method that I am talking about is curPrice2CurPrice method in Currency table.

Below is the code of this method








You have to pass the price and the old currency in which the price actually is and the new currency in which you are converting the price.

Same method is implemented on Purchase Order Form.You can see the existing behavior if you have R2 installed.Just create new purchase order and than create some purchase order lines in it and than in the purchase order header tab change the currency.

After changing the currency the unit price in the purchase order line will convert based on the currency that you have selected.

You can see the below images before and after changing the currency on purchase order.

 Before changing the currency:

  
After changing the currency:

You can also see the exchange rates on the below navigation path:

GL --> Setup --> Exchange rate type --> Set Default --> check currency for which you need to check the exchange rate for

This was related to the currency and exchange rates.
I hope you like it :)

Thanks

Muhammad Zahid.

Wednesday 23 July 2014

Export to Excel: The number of arguments provided is different from the number of arguments accepted by the method.

I was working on excel based reports was getting the following error:

"The number of arguments provided is different from the number of arguments accepted by the method."

After debugging I found out that when I going to insert the text in excel this error was generating.

the code that was reproducing this error is:

cell.value("my text");

The best solution to get rid of this error is that we should open our workbook for very less amount of time.We should first complete all of our calculations and than open the workbook and  insert the records in excel sheet. 

If the issue is not resolve by applying the above workaround than there are also some other solutions available you can see on the below link:  



I hope you like this post.

Thanks

Muhammad Zahid.





Wednesday 25 June 2014

Export to Excel change cell format to percentage format in Microsoft Dynamics AX 2012

Below is the code snippet to change the cell format to percentage format.

cells.range("D21:D30").numberFormat("0.00%");

Below is the link for more info on excel cells format.

http://www.teachexcel.com/free-excel-macros/m-72,Format-Cells-as-a-Percentage-in-Excel-Number-Formatting.html


Thanks

Muhammad Zahid.