Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Monday, February 24, 2014

How to get calenderID in Dynamic AX 2012

Hi,

Pass the worker table recID to hcmEmployment and get hcmEmployment  recID to WorkCalenderEmployement recID
In that WorkCalenderEmployement table you can find the CalenderId
hcmEmployment           = HcmEmployment::getActiveEmploymentsByWorker(HcmWorker.RecId);
workCalendarEmployment  = workCalendarEmployment::findByEmploymentRecId(hcmEmployment.RecId);
return  workCalendarEmployment.CalendarId;

regards,

Sunday, February 23, 2014

How to give 3 fields in look up with filtering one with previous field in Dynamic AX 2012


1.      Create 3 fields for the table “FormTable” and add to form datasource.
2.      First field with relation in table level so automatically you will get the look up.
·         As FormTable.Fild1
3.      Second field with following lookup code, this look up filter with previous field.
·         As FormTable.Fild2
Public void lookup ()
{
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    QueryBuildRange         queryBuildRange;
     QueryBuildRange         queryBuildRange1;
    SysTableLookup          sysTableLookup;
     HRCCompGrid                  HRCCompGrid;
    ;
    //Create an instance of SysTableLookup with the form control passed in
    sysTableLookup = SysTableLookup::newParameters(tablenum(HRCCompRefPointSetupLine), this);
    //Add the fields to be shown in the lookup form
    sysTableLookup.addLookupfield(fieldnum(HRCCompRefPointSetupLine, RefPointId));
    sysTableLookup.addLookupfield(fieldnum(HRCCompRefPointSetupLine, RefPointSetupId));
    //create the query datasource
    queryBuildDataSource = query.addDataSource(tablenum(HRCCompRefPointSetupLine));
    //Only show LocalEndpoints for the current company
    queryBuildRange = queryBuildDataSource.addRange(fieldnum(HRCCompRefPointSetupLine, RefPointSetupId));
    select HRCCompGrid where HRCCompGrid.GridId ==SalaryAmend.GridId ;
//SalaryAmend.GridId is the FormTable.Fild1
    queryBuildRange.value(HRCCompGrid.RefPointSetupId);
//this select query makes the queryBuildRange values from another table for the datasource of another table
    //Assign the query to the lookup form
    sysTableLookup.parmQuery(query);
    // Perform lookup
    sysTableLookup.performFormLookup();
    // Don't call super()
    //super()
}
4.       Third field given a lookup with filtering on based of above 2 fields.
·         As FormTable.Fild3
public void lookup()
{
    Query query = new Query();
    QueryBuildDataSource queryBuildDataSource,qbds;
    QueryBuildRange qbr1,qbr2;
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(HcmCompensationLevel), this);
    sysTableLookup.addLookupfield(fieldnum(HcmCompensationLevel, CompensationLevelId));
    sysTableLookup.addLookupfield(fieldnum(HRCComp, RefPointId));
    sysTableLookup.addLookupfield(fieldnum(HRCComp, GridId));
    queryBuildDataSource = query.addDataSource(tableNum(HcmCompensationLevel));
    qbds = queryBuildDataSource.addDataSource(tableNum(HRCComp));
    qbds.joinMode(JoinMode::ExistsJoin);
    qbds.relations(true);
    qbr1 = qbds.addRange(fieldNum(HRCComp,GridId));
    qbr2 = qbds.addRange(fieldNum(HRCComp,RefPointId));
    qbr1.value(SalaryAmend.GridId);
    qbr2.value(SalaryAmend.RefPointId);
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
    //super();HcmCompensationLevel

}

SQL code to upate one Legal entity banner to all the legal entity in D365

 Hi, update companyimage set  companyimage.Image  = companyimageA.Image  from  ( select Image from companyimage where dataAreaid = 'USF...