Search This Blog

Wednesday, 9 July 2014

X++ code to Count Records in Query


Hi Guys,

The below code is used to count records in query.


static void Query_cntRecords(Args _args)
{
    Query                query = new Query();
    QueryRun             queryRun;
    QueryBuildDataSource qbd;
   
    
    qbd = query.addDataSource(tablenum(CustTable));
    queryRun = new QueryRun(query);
   
    info(strfmt("Total Records in Query %1",SysQuery::countTotal(queryRun)));
   
}

Happy Daxing......

Removing Leading Zeros from a String

Hi Guys,

click here to get the X++ code "how to remove the leading Zeros from a sting in AX?"

Happy Daxing.....

Installation and configuration of EP in AX 2012 R2

Hi Guys,

Today I have referred a wonderful blog where they have neatly explained how to do installation and configuration of EP in AX 2012 R2.

click here

Happy Daxing......
 

Opening Google Webpage using ActiveX control in AX 2012 R3 Forms

Hi ,

Today i am going to share you , how to navigate to webpage using ActiveX control in AX 2012 R3 Form .

Step1:

Create New Form named as WebBrowserForm



Step 2:

Right click the Design node and select ActiveX


Step 3:

Select Microsoft Web Browser from AciveX window


Step 4:

Write some piece of code in init() method of the form

ActiveX.Navigate("www.google.com");

 
Output:

Thus Google page is displayed in AX Form.

Happy Daxing....


Saturday, 21 June 2014

Installation and Configuration of SSAS and SSRS in AX 2012

Hi Guys,

I have gone through a wonderful blog , where they have described about the SSAS, SSRS installation and configuration in AX 2012

click here for SSAS installation

click here for SSRS and SSAS installation

Happy Daxing.....

Saturday, 14 June 2014

Creating a New Sales order by copying existing Sales Order headers and lines in AX 2012

Hi Guys,

Today I am going to explain you , how to copy a existing sales order header and lines and create a new Sales Order.

Step 1:

Add two new control in Form level Design

1) SelectFromExistingSalesId (ControlType-CheckBox)
2)ExistingSalesId(ControlType-StingEdit)



Step 2:
Write a single line of code inside From Level init() method
ExistingSalesId.enabled(false);//Make the ExistingSalesId control Disable when the form open

Step 3:
write a piece of code inside SelectFromExistingSalesId checkbox Control modified() method




public boolean modified()
{
boolean ret;
ret = super();

if(SelectFromExisitngSalesId.value()==1)
{
   ExistingSalesId.enabled(true);
}
else
{
  ExistingSalesId.enabled(false);
}
return ret;

}
Step 4:
create a new method CreateSalesLines in the form level
 
 

public void createSalesLine(SalesId _salesId,ItemId _itemId)
{
SalesLine salesLine;
salesLine.clear();

salesLine.SalesId = _salesId;
salesLine.ItemId = _itemId;

salesLine.createLine(NoYes::Yes, // Validate
NoYes::Yes, // initFromSalesTable
NoYes::Yes, // initFromInventTable
NoYes::Yes, // calcInventQty
NoYes::Yes, // searchMarkup
NoYes::Yes);
}

Step 5:
write a piece of code inside ExistingSalesId Control modified() method

 
public boolean modified()
{
SalesTable salesTableBuff;
SalesLine salesLineBuff;
ItemId existItemId;
SalesId currentSalesId;
SalesIdBase existSalesId;

boolean ret;
ret = super();

existSalesId=ExistingSalesId.valueStr();//Gets the Existing Sales Id

select firstOnly SalesId,CustAccount from salesTableBuff

where salesTableBuff.SalesId == existSalesId;

SalesTable.CustAccount = salesTableBuff.CustAccount;

currentSalesId= SalesTable.SalesId; //Gets the Newly generated Sales Id

SalesTable_ds.object(fieldNum(SalesTable,CustAccount)).modified();

SalesTable.insert();

while select ItemId from salesLineBuff where salesLineBuff.SalesId == existSalesId
{

   existItemId=salesLineBuff.ItemId;
   element.createSalesLine(currentSalesId, existItemId);

}

return ret;

}

Output:
 
A New Sales Oder is Created
 
 


That's it ........

Happy Daxing....



Passing Arguments from One Form to Another Form in AX 2012

Hi Guys,

Today I would like to share you how to pass arguments from one form to another form in AX 2012

Create Two New Table and Two New Form

For an example , I have created two new Table and two new Form

Table 1: SheetTable

 

Table 2:SheetDetails



Form 1 :SheetTable , Datasource Name : SheetTable

Create Ok Button in SheeTable Form


Write a piece of logic in the clicked method



void clicked()
{
Args args;
FormRun formRun;
super();
args = new args();
args.parm(SheetTable.SheetId);

args.record(SheetTable);
args.name( formstr( SheetDetails ) );

formRun = classFactory.formRunClass( Args );
formRun.init();
formrun.run();
formrun.wait();

}
Form 2: SheetDetails , DataSource Name : SheetDetails
 
 
write a piece of code in Form level init() method
public void init()
{
Query query;
QueryBuildRange qbr;
SheetTable _sheetTable;
SheetDetails sheetDetails1;
Str _parmid;
super();
_sheetTable = element.args().record();
_parmid= element.args().parm();
query= new Query();
qbr=query.addDataSource(tableNum(SheetDetails)).addRange(fieldNum(SheetDetails,SheetId));
qbr.value(_parmid);
SheetDetails_ds.query(query);
}
 
Output:
That's it ..........We have done it


Happy Daxing........