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!");

Wednesday, June 17, 2020

New line in ssrs report function, expression

Hi,

In SSRS report, to give a new line in between words then we can use vbCrLf.

Example:

“Signature” + space(2) + “________________________________________” + vbCrLf + “Owner.”

Tuesday, June 16, 2020

Data flow to Invoice Screen while Sales Order Invoicing

Hi,

If you want to know how the data flows to Invoice Screen while Sales Order Invoicing. 
Look into Class "SalesFormletterParmData".

This class process data from SalesOrder to SalesParmTable, which displays while invoicing a SO.

InventItemSalesSetup Table Record Ax 2009

Hello,

I was facing issue in getting InventItemSalesSetup Record in Ax 2009. After few hours of effort, i succeeded in it.

This code below will get you the exact InventItemSalesSetup Record.

//Parm DimId and ItemId
InventItemSalesSetup        InventItemSalesSetup;
InventDim                   InventDim, inventDimSelect;

select inventDimSelect
    where inventDimSelect.inventDimId == _dimId;

select inventItemSalesSetup
    where   InventItemSalesSetup.ItemId         ==  _itemId
    join inventDim
    where inventDim.inventDimId == inventItemSalesSetup.InventDimId
    && inventDim.InventColorId == inventDimSelect.InventColorId
    && inventDim.InventSizeId == inventDimSelect.InventSizeId
    && inventDim.ConfigId == inventDimSelect.configId;

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

Hi,
Below code will help to Import and create Multiple 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,type1; int row=1,row1=1; ; application = SysExcelApplication::construct(); workbooks = application.workbooks(); workbooks.open('File Path \\SalesOrderCreate.xlsx'); workbook = workbooks.item(1); worksheets = workbook.worksheets(); worksheet = worksheets.itemFromName("Header"); //Worksheet with name "Header" worksheet1 = worksheets.itemFromName("Lines"); cells = worksheet.cells(); cells1 = worksheet1.cells(); ttsBegin; do { row1++; salesTable.clear(); num = NumberSeq::newGetNum(SalesParameters::numRefSalesId()); salesTable.SalesId = num.num(); salesTable.CustAccount = cells.item(row1,1).value().bStr(); salesTable.initValue(SalesType::Sales); salesTable.initFromCustTable(); salesTable.insert(); do { row++; if( salesTable.CustAccount == cells1.item(row, 1).value().bStr()) { inventDim.clear(); inventDim.InventSiteId = cells1.item(row,5).value().bStr();//int2str(real2int(cells1.item(row,5).value().double())); inventDim.InventLocationId = cells1.item(row,6).value().bstr();//int2str(real2int(cells1.item(row,6).value().double())); salesLine.clear(); salesLine.initValue(salesTable.SalesType); salesLine.initFromSalesTable(salesTable); salesLine.ItemId = cells1.item(row, 2).value().bStr(); salesLine.initFromInventTable(InventTable::find(cells1.item(row, 2).value().bStr())); salesLine.InventDimId = InventDim::findOrCreate(inventDim).inventDimId; salesLine.SalesQty = any2int(cells1.item(row,3).value().toString()); salesLine.RemainSalesPhysical = salesLine.SalesQty; salesLine.SalesUnit = cells1.item(row,4).value().bStr(); salesLine.DlvMode = cells1.item(row,7).value().bStr(); salesLine.QtyOrdered = salesLine.calcQtyOrdered(); salesLine.RemainInventPhysical = salesLine.QtyOrdered; salesLine.setPriceDisc(InventDim::find(salesLine.InventDimId)); if (salesLine.validateWrite()) { salesLine.insert(); } } type = cells1.item(row+1, 1).value().variantType(); } while (type != COMVariantType::VT_EMPTY); row = 0; type1 = cells.item(row1+1, 1).value().variantType(); } while(type1 != COMVariantType::VT_EMPTY); workbooks.close(); application.quit(); info("Done!"); ttsCommit;

Wednesday, March 18, 2020

Passing ranges as per selection in form, using execute query - X++

Hi,

This post will show you yo filter the values as per user selection in the form.

Assume a form has two controls such as,

1."sales status" - this will filter as per status of Sales Order.

2."creator" -  this will filter Sales Order as per the current user.

Below code will get the value from the form control and filter as such:

public void executeQuery()
{
;
SalesTable_ds.query().dataSourceTable(tableNum(SalesTable)).clearRanges();
if(statusFilter.valueStr() == enum2str(SalesStatus::Backorder))
{  SalesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addRange(fieldnum(SalesTable,SalesStatus)).value(sysquery::value(SalesStatus::Backorder));
}
else if(statusFilter.valueStr() == enum2str(SalesStatus::Delivered))
{   SalesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addRange(fieldnum(SalesTable,SalesStatus)).value(sysquery::value(SalesStatus::Delivered));
}
else if(statusFilter.valueStr() == enum2str(SalesStatus::Invoiced))
{
SalesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addRange(fieldnum(SalesTable,SalesStatus)).value(sysquery::value(SalesStatus::Invoiced));
}

if(CreatorFilter.value() == true)
{
SalesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addRange(fieldnum(SalesTable,CreatedBy)).value(sysquery::value(curUserId()));
}
    super();
}

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...