Thursday 27 March 2014

Total amount display

display Amount totalAmount()
{
    SalesLine       salesLine;
    ;
    select sum(LineAmount) 
        from salesLine 
            where salesLine.SalesId == this.SalesId;
    return salesLine.LineAmount;
}

Wednesday 26 March 2014

Table level display method

public void modifiedField(FieldId _fieldId)
{
    super(_fieldId);
    if(_fieldId == fieldNum(Paymentrequest, Name))
    {
        this.Descripation = LedgerJournalName::find(this.Name).Name;
    }
}

Monday 17 March 2014

Type of Joins and Linked Type in AX 2009

Diffrent Type of Joins and Linked Type in AX 2009


Different type of Joins and Link Type

Car Table

CarId
ModelYear
CarBrand
Model
Mileage
ModelYear
CarId
CA101
2008
Mahindra
Scorpio
15
2008
CA101
CA102
2009
Suzuki
800
12
2009
CA102
CA103
2007
Hundai
i20
5
2007
CA103
CA104
2007
Toyato
Inova
3
2007
CA104
CA105
2009
BMW
 
5
2009
CA105
CA106
2010
Benz
AZ12
10
2010
CA106

 
Rental Table

RentalId
CustAccount
CarId
FromDate
ToDate


RE101
1104
CA101
10/12/2010
10/29/2010

RE102
1102
CA102
11/17/2010
12/14/2010

RE103
1203
CA103
11/24/2010
12/15/2010

RE104
1301
CA104
12/10/2010
1/5/2011


RE105
1304
CA101
1/3/2011
1/18/2011


RE108
1303
 
 
 
 
 
RE107
1202
 
 
 
 
 
RE106
2024
CA103
1/10/2011
1/29/2011




 
Inner Join

Select records from main table that have matching record form join table.

Main table record and join table records are joined together  and show as single record.

Code                                                                                                                                                   

static void JoinExamples(Args _args)                                                                                                      

{                                                                                                             

    CarTable carTable;                                                                                                      

    RentalTable rentalTable;                                                                                                          

    ;                                                                                                          

    while select carTable join rentalTable                                                                                                

        order by carTable.CarId                                                                                                        

        where carTable.CarId == rentalTable.CarId                                                                                                 

                                                                                                               

        {                                                                                                     

            info(strfmt("Car id is %1 renatla id is %2",carTable.CarId, rentalTable.RentalId));                                                                                                  

        }                                                                                                     

}

               
Output                                                                                 


Outer Join                                                                          

                                                                               

Select all the records from main table and related records from join table                                                                                                                                           

If there is no match, the field from join table is empty                                                                   

Code

while select carTable outer  join rentalTable                                                                                                       

        order by carTable.CarId                                                                                                        

        where carTable.CarId == rentalTable.CarId 

Output



Exists Join                                                                                                                                                                                          

Selecting record from main table only if there is matching record in join table.                                   

It shoul be return only main table record, not a related table record.                                                                      

Code

while select carTable Exists  join rentalTable                                                                                                       

        order by carTable.CarId                                                                                                        

        where carTable.CarId == rentalTable.CarId 

Output



 

Not Exists Join                                                                                                                                                                 

Selecting record from main table only if there is not matching record in join table.                           

It is directly irrelevant to the Exists join.                

Output                

           

 
Link Type:  Delayed

A pause is inserted before linked child data sources are updated. This enables faster navigation in the parent data source because the records from child data sources are not updated immediately.

Form Output



Form Design in Data Source Level:



 

Link Type: Active

The child data source is updated immediately when a new record in the parent data source is selected. Continuous updates consume lots of resources.

Link Type: Passive

Linked child data sources are not updated automatically. Updates of the child data source must be programmed on the active method of the master data source.

Friday 14 March 2014

direct report open

EX:
Step1:

class DNGRMRentalQuotationReportController extends SrsReportRunController
{
    #define.ReportName('DNRentalQuotationReport.LineReport')
    SalesQuotationTable salesQuotationTable ;
 }


Step 2: 
public void setRange(Args _args, Query _query)
{
    QueryBuildDataSource qbds;
    QueryBuildRange qbr;
    if (_args && _args.dataset())
    {
        switch(_args.dataset())
        {
            case tableNum(SalesQuotationTable) :
                SalesQuotationTable = _args.record();
                break;
        }
    }
    qbds = _query.dataSourceTable(tableNum(SalesQuotationTable));
    qbds.clearRanges();
    qbr = qbds.findRange(fieldName2id(tableNum(SalesQuotationTable),fieldStr(SalesQuotationTable, QuotationId)));
    if (!qbr)
    {
        qbr = qbds.addRange(fieldNum(SalesQuotationTable, QuotationId));
    }
    if(SalesQuotationTable)
    {
        qbr.value(SalesQuotationTable.QuotationId);
    }
}

Step 3: 

public static DNGRSSalesQuotationReportController construct(Args _args)
{
    DNGRSSalesQuotationReportController controller=new DNGRSSalesQuotationReportController();
    controller.parmArgs(_args);
    return controller;
}

Step4 :

public static void main(Args _args)
{
    DNGRMRentalQuotationReportController controller = new DNGRMRentalQuotationReportController();
    controller.parmReportName(#ReportName);
    controller.parmArgs(_args);
    controller.setRange(_args, controller.parmReportContract().parmQueryContracts().lookup(controller.getFirstQueryContractKey()));
    controller.parmShowDialog(false); 
    controller.startOperation();
 }

Wednesday 12 March 2014

Table methods using ValidateWrite() ValidateDelete() initValue() ModifiedField() - Microsoft Dynamics AX 2009



Table methods using ValidateWrite()  ValidateDelete() initValue() ModifiedField()

initValue() This method file while creating new record to initialize a value, here I am assigning user id to the userID field.

public void initValue()
{
super();
this.UserId = curuserid();
}

ValidateDelete() While deleting a record if we want to put any validation we can use this method. Here once I delete a record populating a info that deleted record.

public boolean validateDelete()
{
boolean ret;
ret = super();
info(this.AccountNum);
return ret;
}

ValidateWrite()

This method will get to fire when we update a record. here I am using to check mandatory field for address AccountNum

public boolean validateWrite()
{
boolean ret;
;
if(this.Address != "")
ret = super();
else
warning(" Please fill the address value");
return ret;
}

ModifiedField()

This method will execute if modified a record value, this works based on the field value.
Here I am using to fill the name field value according to the AccountNum

public void modifiedField(fieldId _fieldId)
{
CustTable ct;
;
super(_fieldId);
switch(_fieldId)
{
case fieldNum(Cust_new,AccountNum) :
{
this.Name = CustTable::find(this.AccountNum).Name;
}
break;
}

}

Thursday 6 March 2014

Removing Product categories from product master



   static void categoryherirachy_Deleted(Args _args)
    {
       inventtable  _invent;
   
       EcoResProductCategory   _ecoresproductacte;
        RetailSpecialCategoryMember categoryMember;
   
   
   
       while  select * from _invent where _invent.ItemId like "ASTW*"   //mention the items
        {
            // info(strFmt("done %1",_invent.Product));
   
   
   
   
        select  forUpdate * from _ecoresproductacte where _ecoresproductacte.Product == _invent.Product;
        if(_ecoresproductacte)
        {
   
   
   
   
        if (isConfigurationkeyEnabled(configurationKeyNum(Retail)))
        {
            // if special group
            if (EcoResCategoryHierarchyRole::existRoleHierarchyPair(
                        EcoResCategoryNamedHierarchyRole::RetailSpecialGroup,
                       _ecoresproductacte.CategoryHierarchy))
            {
                categoryMember = RetailSpecialCategoryMember::findByMemberLine(
                        _ecoresproductacte.Category,
                        0,
                        _ecoresproductacte.Product,
                        0,
                        true);
   
               if (categoryMember)
                {
                    // this will cascade to the member line.
                    categoryMember.delete();
                }
            }
       }
   
   
     
   
   
        ttsBegin;
        _ecoresproductacte.delete();
           ttsCommit;
   
   
        info(strFmt("category deleted for item  %1",_invent.ItemId));
        }
        }
    }

SQL/SSRS Interview questions I thought of blogging some SQL/SSRS interview questions.

Below are some. I will add more, when I complete the compilation 1. What is OLTP(Online Transaction Processing)? OLTP stands ...