Alfasith AX

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

Monday, August 5, 2013

Validating two date fields in Dynamic AX

Hi,

1.Create two fields as UtcDateTimeEdit of table TableName
2.Name it InTime and OutTime.
3.In the init() of that datasource or form depends on requirements.

    TableName.InTime = DateTimeUtil::getSystemDateTime();
    TableName.OutTime = DateTimeUtil::getSystemDateTime();
//here making the system date and time to the that field.

3.Override the modified method by modified each of the fields.

public boolean modified()
{
    boolean ret;

    ret = super();

    if(SMAServiceOrderTable.InTime > SMAServiceOrderTable.OutTime)
    {
        warning("In time cannot be greater than Out time");
        SMAServiceOrderTable.InTime = DateTimeUtil::getSystemDateTime();
        SMAServiceOrderTable.OutTime = DateTimeUtil::getSystemDateTime();
    }

    return ret;
}

Wednesday, July 24, 2013

Creating the Query in job - Dynamic AX

static void CustTableSales1(Args _args)

{
    Query       query;
    QueryRun    queryrun;
    QueryBuildDataSource    qbds1,qbds2;
    QueryBuildRange         qbr1,qbr2;
    CustTable               custTable;
    ;
    query   = new query();
    qbds1   =   query.addDataSource(tablenum(CustTable));
    qbds1.addSortField(fieldnum(custTable,AccountNum),Sortorder::Descending);
    qbr1    = qbds1.addRange(fieldnum(custTable,custGroup));
    qbr1.value(queryvalue('10'));
    qbr2    =  qbds1.addRange(fieldnum(custTable,Blocked));
    qbr2.value(queryvalue(CustVendorBlocked::No));
    qbds2   = qbds1.addDataSource(tablenum(SalesTable));
    qbds2.relations(false);
    qbds2.joinMode(joinmode::ExistsJoin);
    qbds2.addLink(fieldnum(CustTable,AccountNum),fieldnum(SalesTable,CustAccount));
    queryrun    = new queryrun(query);
    while(queryrun.next())
    {
        custTable   = queryrun.get(tablenum(custTable));
        info(strfmt('%1 – %2',custtable.AccountNum,custTable.name()));
    }
}





//Another sample code///

Query                   query; 
QueryRun                queryRun; 
QueryBuildDataSource    queryBuildDataSource; 
QueryBuildRange         queryBuildRange; 
CustTable               custTable; 
query = new Query(); 
queryBuildDataSource = query.addDataSource(TableNum(CustTable)); 
queryBuildRange = queryBuildDataSource.addRange(FieldNum(CustTable,AccountNum)); 
queryBuildRange.value("4000..5000"); 
queryRun = new queryRun(query); 
if (queryRun.prompt()) 
{ 
    while (queryRun.next()) 
    { 
        custTable = queryRun.get(TableNum(CustTable)); 
        print custTable.AccountNum; 
    } 
}

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