Search This Blog

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

Monday, 26 May 2014

Adding CustomDataSet Lookup in AXGridview in EP in AX 2012


<asp:TemplateField ConvertEmptyStringToNull="False" HeaderText="Recruiter"
          SortExpression="Recruiter">
        <EditItemTemplate>
          <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("custRecruiter") %>'> >
          </asp:TextBox>
            <dynamics:AxLookup ID="AxLookup1" runat="server"  TargetControlId="TextBox1"
            onlookup="WorkOrdersLookup_Lookup" RunLookupDataSetWhenOkClicked="True"
             AutoPostBack="False">
            </dynamics:AxLookup>
         </EditItemTemplate>
         <ItemTemplate>
         <asp:Label ID="Label1" runat="server" Text='<%# Bind("custRecruiter") %>'>>
         </asp:Label>
         </ItemTemplate>
 </asp:TemplateField>


using Microsoft.Dynamics.Framework.BusinessConnector.Session;
using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy;
using Microsoft.Dynamics.AX.Framework.Services.Client;
using Microsoft.Dynamics.AX.Framework.Portal.Data;

   private ISession AxSession
    {
        get
        {
            AxBaseWebPart webpart = AxBaseWebPart.GetWebpart(this);
            return webpart == null ? null : webpart.Session;
        }
    }


    protected void WorkOrdersLookup_Lookup(object sender, AxLookupEventArgs e)
    {

    AxLookup lookup = (AxLookup)sender;

    // Create the lookup data set. The DirParty table will be used.
    Proxy.SysDataSetBuilder sysDataSetBuilder;
    sysDataSetBuilder = Proxy.SysDataSetBuilder.constructLookupDataSet(AxSession.AxaptaAdapter, TableMetadata.TableNum(AxSession, "DirPartyTable"));

    // Set the generated data set as the lookup data set.
    lookup.LookupDataSet = new DataSet(AxSession, sysDataSetBuilder.toDataSet());

    //filter the lookup

    using (Proxy.Query query = lookup.LookupDataSet.DataSetViews[0].MasterDataSource.query())
    {
        // If the partyName is blank we assign the "*" as the range
        query.dataSourceNo(1).addRange(TableDataFieldMetadata.FieldNum(this.AxSession, "DirPartyTable", "Name")).value = "Ajay";
    }
       
  
    // Specify the fields for the lookup.
 
    lookup.Fields.Add(AxBoundFieldFactory.Create(AxSession, lookup.LookupDataSetViewMetadata.ViewFields["Name"]));
   
  
    // Specify the select field for the lookup.
    lookup.SelectField = "Name";

    }

Friday, 23 May 2014

Models in Ax 2012

Hi Guys,

click here to have a clear idea about Models in Ax 2012.

Thanks & Regards,
Banupriya

Saturday, 3 May 2014

EP in AX 2012

Hi Guys,

Please refer this link which will be useful for you while you are working in EP in Ax 2012.

click here

Thanks,
Banupriya

X++ Implementation of few SQL Keywords


Keyword Example
asc Set the sorting order to ascending. All selects are default fetching data ascending.
Syntax: select custTable order by accountNum asc;
 
desc Set the sorting order to descending. Used in combination with order by or group by.
Syntax: select custTable order by name desc;
AX Example: See table method CustTable.lastPayment().
 
avg Select uses aggregate keyword (avg) using only one call to the database calculating a result based on multiple records
Syntax: select avg(amountMST) from custTrans;
AX Example: See class method KMKnowledgeCollectorStatisticsExecute.runQuery().
 
count Aggregate keyword used to count the number of records fetched.
Syntax: select count(recId) from custTrans;
AX Example: See class method KMKnowledgeCollectorStatisticsExecute.runQuery().
 
sum Aggregate keyword used to sum values of a field fetched.
Syntax: select sum(amountMST) from custTrans;
AX Example: See class method KMKnowledgeCollectorStatisticsExecute.runQuery().
 
maxof Aggregate keyword used to return the highest field value fetched
Syntax: select maxOf(amountMST) from custTrans;
AX Example: See class method KMKnowledgeCollectorStatisticsExecute.runQuery().
 
minof Aggregate keyword used to return the lowest field value fetched.
Syntax: select minOf(amountMST) from custTrans;
AX Example: See class method KMKnowledgeCollectorStatisticsExecute.runQuery().
 
delete_from Will delete multiple records in one call to the database.
Syntax: delete_from myTable where myTable.amountMST <='1000';
AX Example: See class method InventCostCleanUp.updateDelSettlement().
 
exists join Exists join is used to fetch records where at least one record in the secondary table matches the join expression.
No records will be fetched from the secondary table using exists join.
Syntax: while select custTable exists join custTrans
where custTable.accountNum == custTrans.accountNum
AX Example: See class method InventAdj_Cancel.cancelInventSettlements().
 
notexists join Opposite of exists join. Will fetch records from the primary table, where no records in the secondary table match the join expression.
Syntax: while select custTable notexists join custTrans
where custTable.accountNum == custTrans.accountNum
AX Example: See class method InventConsistencyCheck_Trans.run().
 
outer join Outer join will select records from both tables regardless if there are any records in the secondary table matching the join expression.
Syntax: while select custTable outer join custTrans
AX Example: See class method SysHelpStatistics.doTeams().
 
join Join will fetch Records matching the join expressionfrom both tables. (innerjoin)
Syntax: while select custTable join custTrans
where custTable.accountNum == custTrans.accountNum
AX Example: See table method SalesTable.LastConfirm().
 
firstfast Instruct to select the first record faster. used in situations where only one record is shown, like in a dialog.
Syntax: select firstfast custTable order by accountNum;
AX Example: See class method ProjPeriodCreatePeriod.dialog().
 
firstonly First record will be selected. Firstonly should always be used when not using while in selects.
Syntax: select firstonly custTable where custTable.AccountNum == _custAccount (variable)
AX Example: See Table method CustTable.find().
 
forupdate Used If records in a select are to be updated
Syntax: while select forupdate reqTransBOM where reqTransBOM.ReqPlanId     ==  this.ReqPlanId
AX Example: See Table method ReqTrans.deleteExplosionCoverage().
 
from Default all fields of a table is selected. From is used to select only the fields specified.
Use it for optimization only, as it makes the code more complex.
Syntax: select accountNum, name from custTable;
 
group by Sort the fetched data group by the fields specified. Only the fields specified in the group by will be fetched.
Syntax: while select custTable group by custGroup;
AX Example: See class method InventStatisticsUS.calcTotals().
 
index Used to set the sorting order of the fetched data. The kernel will convert the keyword index to an order by using the fields from the index.
Index should only be used if the fetched data must be sorted in a specific way, as the database will choose a proper index.
Syntax: while select custTable index accountIdx.
 
index hint Index hint will force the database to use the specified index.
Syntax: while select custTable index hint accountIdx.
AX Example: See Table method ReqTrans.deleteExplosionCoverage().
 
insert_recordset Used to insert multiple records in a table. Insert_recordset is useful when copying data from one table to another as it only requires one call to the database
Syntax: insert_recordset myTable (myNum,mySum)
select myNum, sum(myValue) from anotherTable group by myNum where myNum <= 100;
AX Example: See class method SysLicenseCodeReadFile.handleDomainLicenseChanges().
 
update_recordset Used  to update multiple records in one database call. Useful to initialize fields in a fast way.
The fields updated are specified after thekeyword setting.
Syntax: update_recordset myTable setting field1 = myTable.field1 * 1.10;
AX Example: See class method ProdUpdHistoricalCost.postScrap().