Alfasith AX

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

Wednesday, August 7, 2013

Debug the report in AX 2012


Hi


static void AlfasithDpDebug(Args _args)
{

    NQ_smmActivitiesDP    NQ_smmActivitiesDP;
    NQ_smmActivitiesDP   dataprovider = new NQ_smmActivitiesDP();
    NQ_smmactivitiesContract contract = new NQ_smmactivitiesContract();
    smmActivitiesTmp      smmActivitiesTmp;
    query q;

    contract.param_application(5637147580);
    q = dataprovider.parmQuery();
    //q.dataSourceTable(tableNum(SalesQuotationTable)).addRange(fieldNum(SalesQuotationTable, WorkerSalesResponsible)).value(""); //000545"); //"000042"); //"DNG998877");
    q.dataSourceTable(tableNum(smmActivities)).addRange(fieldNum(smmActivities, responsibleworker)).value(""); //000545"); //"000042"); //"DNG998877");
    dataprovider.parmDataContract(contract);
    dataprovider.processReport();
    smmActivitiesTmp = dataprovider.getsmmActivitiesTmp();

     select firstOnly smmActivitiesTmp;
    print smmActivitiesTmp.NQ_NContactperson;
   //print smmActivitiesTmp;
    pause;
    }

Monday, August 5, 2013

lookup with joinning 2 tables in Dynamic AX

Implement this code in the lookup() method of the field where you need the lookup to be displayed.

NS: The same code can be written in three places to achieve the lookup.
1) Under AOT->Table->Method and cal this method from the form design where you want to display the lookup.
2) Form->Datasource->Table->Field->method
3) Form->Design->Field->Method.

public void lookup()
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource QbdsJoin;

// Instantiate sysTableLookup object using table which will provide the visible fields
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(TableName), this);
;

// Create the query.
qbds= query.addDataSource(tableNum(TableName));
qbds.addRange(fieldNum(TableName, FieldName)).value('Value');

//Join Table
QbdsJoin= qbds.addDataSource(tableNum(TableName2));
QbdsJoin.relations(true);
QbdsJoin.joinMode(JoinMode::ExistsJoin);
QbdsJoin.addRange(fieldNum(TableName2, Fieldname)).value('Value');

// Set the query to be used by the lookup form
sysTableLookup.parmQuery(query);

// Specify the fields to show in the form.
sysTableLookup.addLookupfield(fieldNum(TableName, FiledName));
sysTableLookup.addLookupfield(fieldId2Ext(fieldNum(TableName, Dimension), 1));

// Perform the lookup
sysTableLookup.performFormLookup();
}

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