Hi Muhammad Zahid here welcome to my blog.I will help you out in Programming issues in Microsft Dynamics Ax and related Microsoft Technologies.
Search This Blog
Thursday, 25 September 2014
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.
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.
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:
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.
"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.
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.
Export to Excel in Microsoft Dynamics AX 2012
Below is the sample code snippet to export the data from Microsoft Dynamics AX to Excel.
Example no 1:
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbook = workbooks.add();
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
cell = cells.item(row, col);
cell.value("sample Code");
worksheet.columns().autoFit(); //use to autofit the columns of the excel sheet
application.visible(true);
IF you want to print some Headings in Bold format and in more than one cell:
Example No 2:
fontSizeRange = #B+int2str(2)+","+#C+int2str(2);
mergeCellsRange = #B+int2str(2)+":"+#C+int2str(2);
this.insertValue(row,col,"Project Comparison Budget VS Actual",true,fontSizeRange,13,true,mergeCellsRange,false,0);
public void insertValue(int _row,
int _col,
anytype _value,
boolean _isFontBold = false,
str _fontSizeRange = "",
int _fontSizeWeight = 11,
boolean _isMergeCell = false,
str _mergeRange = "",
boolean _allignment = false,
int _allignmentType = #xlLeft)
{
cell = this.parmCells().item(_row, _col);
cell.value(_value);
if (_isFontBold)
{
font = cell.font();
font.bold(_isFontBold);
}
if (_fontSizeRange != "")
{
worksheetCOM = this.parmWorksheet().comObject();
rangeCOM = worksheetCOM.Range(_fontSizeRange);
fontCOM = rangeCOM.Font();
fontCOM.Size(_fontSizeWeight);
}
if (_isMergeCell)
{
range = this.parmCells().range(_mergeRange);
range.comObject().MergeCells(1);
}
if (_allignment)
{
if (_isMergeCell)
{
range.horizontalAlignment(_allignmentType);
}
else
{
cellCOM = cell.comObject();
range = this.parmCells().range(cellCOM.address()+":"+cellCOM.address());
range.horizontalAlignment(_allignmentType);
}
}
}
This was all related to the export to excel.
If you have any query related to export to excel than feel free to comment.
Thanks
Muhammad Zahid
Example no 1:
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbook = workbooks.add();
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
cell = cells.item(row, col);
cell.value("sample Code");
worksheet.columns().autoFit(); //use to autofit the columns of the excel sheet
application.visible(true);
IF you want to print some Headings in Bold format and in more than one cell:
Example No 2:
fontSizeRange = #B+int2str(2)+","+#C+int2str(2);
mergeCellsRange = #B+int2str(2)+":"+#C+int2str(2);
this.insertValue(row,col,"Project Comparison Budget VS Actual",true,fontSizeRange,13,true,mergeCellsRange,false,0);
public void insertValue(int _row,
int _col,
anytype _value,
boolean _isFontBold = false,
str _fontSizeRange = "",
int _fontSizeWeight = 11,
boolean _isMergeCell = false,
str _mergeRange = "",
boolean _allignment = false,
int _allignmentType = #xlLeft)
{
cell = this.parmCells().item(_row, _col);
cell.value(_value);
if (_isFontBold)
{
font = cell.font();
font.bold(_isFontBold);
}
if (_fontSizeRange != "")
{
worksheetCOM = this.parmWorksheet().comObject();
rangeCOM = worksheetCOM.Range(_fontSizeRange);
fontCOM = rangeCOM.Font();
fontCOM.Size(_fontSizeWeight);
}
if (_isMergeCell)
{
range = this.parmCells().range(_mergeRange);
range.comObject().MergeCells(1);
}
if (_allignment)
{
if (_isMergeCell)
{
range.horizontalAlignment(_allignmentType);
}
else
{
cellCOM = cell.comObject();
range = this.parmCells().range(cellCOM.address()+":"+cellCOM.address());
range.horizontalAlignment(_allignmentType);
}
}
}
This was all related to the export to excel.
If you have any query related to export to excel than feel free to comment.
Thanks
Muhammad Zahid
SSRS Reports Range Bar Chart Show Start and End Date Only
Below are the steps to show the start and end date only in a range bar chart in SSRS reports.
First of all just select the Horizontal Axis of the chart as you can see this in the below image.
Now right click this horizontal axis and than select axis properties.
A new window will open select the first tab i.e Axis Options.As you can see this window in the below image.
As you can see in the above image in the minimum text box select the startdate and in the maximum text box select the end date and in the interval write the expression i.e
=datediff("d", Fields!PSASchedStart.Value, Fields!PSASchedEnd.Value)
after that click ok and than save the report.
After running the report you will see that you can only see the start and end dates in the range bar chart as you can see in the below image.
This was all related to the range bar chart showing the start and end date only.
Below is the link for more information
http://stackoverflow.com/questions/18004792/ssrs-chart-x-axis-show-start-and-end-date-only
If you have any issues feel free to comment on this.
Thanks
Muhammad Zahid.
First of all just select the Horizontal Axis of the chart as you can see this in the below image.
Now right click this horizontal axis and than select axis properties.
A new window will open select the first tab i.e Axis Options.As you can see this window in the below image.
As you can see in the above image in the minimum text box select the startdate and in the maximum text box select the end date and in the interval write the expression i.e
=datediff("d", Fields!PSASchedStart.Value, Fields!PSASchedEnd.Value)
after that click ok and than save the report.
After running the report you will see that you can only see the start and end dates in the range bar chart as you can see in the below image.
This was all related to the range bar chart showing the start and end date only.
Below is the link for more information
http://stackoverflow.com/questions/18004792/ssrs-chart-x-axis-show-start-and-end-date-only
If you have any issues feel free to comment on this.
Thanks
Muhammad Zahid.
Subscribe to:
Posts (Atom)