DAXSPOT

Thursday, October 29, 2020

Append Text to String or append two texts to a string in X++

Hi All,

Simple way to concatenate String in x++ is using plus(+) sign or strFmt function.

List of concatenating methods in x++:

strFmt

str ss = strFmt('Name=%1, Surname=%2, Phone Number=%3', nameStr, surnameStr, phNum);

+ Sign

str ss = 'Name=' + nameStr+ ', Surname=' + surnameStr+ ', Phone Number=' + phNum;

System.String::Concat
System.String s1 = System.String::Concat('Name=', nameStr);
System.String s2 = System.String::Concat(', Surname=', surnameStr);
System.String s3 = System.String::Concat(', Phone Number=', phnNum);
System.String s4 = System.String::Concat(s2, s3, ', Gender=', genderStr);
str s5 = System.String::Concat(s1, s4);
System.Text.StringBuilder
System.Text.StringBuilder sb = new System.Text.StringBuilder();
   
sb.Append("Name=");
sb.Append(nameStr);
sb.Append(", Surname=");
sb.Append(surnameStr);
sb.Append(", Phone Number=");
sb.Append(phnNum);
str result = sb.ToString();
info(result);
The Result:
1000000 strFmt took 0.00 milliseconds in average, in total 3398
1000000 +ing took 0.00 milliseconds in average, in total 1843
1000000 System.String::Concat took 0.00 milliseconds in average, in total 655
1000000 System.Text.StringBuilder took 0.00 milliseconds in average, in total 896

Reference: http://devlicious.net/

Monday, October 19, 2020

show or hide the "Select" button in a parameter dialog when we run the report - SSRS Report

Hi,

This below code will help you to show or hide the "Select" button in a parameter dialog when we run the ssrs report.

We just need to add this method in controller class.
public  boolean  showQuerySelectButton(str parameterName)
{
    return false;
}

Friday, October 9, 2020

Pass a range of enum value - X++ Code

Hi,

Today i will be sharing the code to pass the range of a enum value while working in x++ query or adhoc query.

SalesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addRange(fieldnum(SalesTable,SalesStatus)).value(sysquery::value(SalesTable::Invoiced));

Monday, October 5, 2020

Import from excel and create Sales Order with Multiple Sales Lines in ax 2012

Hi,

Below code will help to Import and create Sales Order with Multiple Lines in ax 2012.
This has some reference from other blogs.

SalesTable      salesTable;
SalesLine       salesLine;
InventDim       inventDim;
NumberSeq        num;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet,worksheet1;
SysExcelCells cells,cells1;
COMVariantType type;
int row;
;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbooks.open('File Path \\SalesOrderCreate.xlsx'); //file path
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromName("Header");
worksheet1 = worksheets.itemFromName("Lines");
cells = worksheet.cells();
cells1 = worksheet1.cells();
 
num = NumberSeq::newGetNum(SalesParameters::numRefSalesId());
salesTable.SalesId = num.num();
 
salesTable.CustAccount = cells.item(1,1).value().bStr();
salesTable.initValue(SalesType::Sales);
salesTable.initFromCustTable();
if(salesTable.validateWrite())
{
salesTable.insert();
}
 
do
{
row++;
inventDim.clear();
inventDim.InventSiteId = int2str(real2int(cells1.item(row,4).value().double()));
inventDim.InventLocationId = int2str(real2int(cells1.item(row,5).value().double()));
 
salesLine.clear();
salesLine.initValue(salesTable.SalesType);
salesLine.initFromSalesTable(salesTable);
salesLine.ItemId = cells1.item(row, 1).value().bStr();
salesLine.initFromInventTable(InventTable::find(cells1.item(row, 1).value().bStr()));
salesLine.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;
salesLine.SalesQty = any2int(cells1.item(row,2).value().toString());
salesLine.RemainSalesPhysical = salesLine.SalesQty;
salesLine.SalesUnit = cells1.item(row,3).value().bStr();
salesLine.QtyOrdered = salesLine.calcQtyOrdered();
salesLine.RemainInventPhysical = salesLine.QtyOrdered;
salesLine.setPriceDisc(InventDim::find(salesLine.InventDimId));
 
type = cells1.item(row+1, 1).value().variantType();
if (salesLine.validateWrite())
{
salesLine.insert();
}
}
while (type != COMVariantType::VT_EMPTY);
 
workbooks.close();
application.quit();
 
info("Done!");

How to execute SQL directly form Dynamics AX X++

How to execute Sql directly form Dynamics AX X++ Reference by : alirazazaidi Dynamics Ax provide many other ways to communicate with databas...