May 30, 2012

How to find All Usr Layer Element in AOT

How to Find all the elements which in present in USR layer

To find all USR layer elements in AOT , you can write job with following code, when you will run this job it will create a new project named "TheAxapta_UsrObject". In this Project you find all elements which is present in USR layer by individual grouping. This a good way to find all USR element.

static void FilterBasedOnLayers(Args _args)
{

    sysprojectfilterrunbase upgradeproject;
    utilelements            theelements;
    ;

    upgradeproject = new sysprojectfilterrunbase();
    upgradeproject.parmProjectNode(systreenode::createProject('theaxapta_UsrObject'));
    upgradeproject.grouping(sysprojectgrouping::AOT);

    while select name, utilLevel, RecordType, ParentId from theelements

    where theelements.utilLevel == UtilEntryLevel::usr
    {
        try
        {
            theelements.reread();
            upgradeproject.doUtilElements(theelements);
        }

        catch (exception::Error)
        {
            throw error('error');
        }
    }

    upgradeproject.write();

    info('finish');
}

When this job is finished you get a new project in your Share Project node.
-Harry

May 29, 2012

How to convert a Amount in Words


Hi Folks,

This code will work for the report as well as Forms also.  Of course this a lengthy code but you can write this in a class also for reuse this code.



-Harry

May 28, 2012

Join Two Tables at Run Time

How to join Two tables at RunTime, without using Datasource


static void QueryJoin2Tables(Args _agrs)
{
AxTestTable1 AxTestTable1;  // Table 1
AxTestTable2 AxTestTable2;  // another table which you want to join with table 1
Query q;
QueryBuildDataSource qbdAxTestTable1, qbdAxTestTable2;  // objects for both tables
QueryBuildRange qbr;
QueryRun qr;
;

        q = new Query(); //to make a new query

qbdAxTeatTable2 = q.addDataSource(tablenum(AxTestTable2)); // To Add table to query

        qbdAxTesttable2.addRange(fieldnum(AxTestTable2,RollNo)).value("2");

         qbdAxTeatTable1 = qbdAxTestTable2.adddataSource(tablenum(AxTestTable));

       qbdAxTesttable1.addlink(fieldnum(AXTestTable2,RollNo),fieldnum(AxTestTable,Rollno));

       qbdAxTestTable.joinMode(joinMode::InnerJoin);
    qr = new QueryRun(q); // to fetch records from query
while(qr.next())
{
AxTestTable1 = qr.get(tablenum(AxTestTable));
info(AxtestTable.RollNo);
}
}

-Harry

May 25, 2012

Send Method


Hi frnd,

Overload your send method and copy paste following code, n yes dont forget to change the tables name here...



All d best ............:)


public boolean send(Common _cursor, int _level=1, boolean _triggerOffBody=TRUE, boolean_newPageBeforeBody=FALSE)
{
    boolean ret;
    LedgerJournalTrans ledgerJournalTrans1;

    if (_cursor.tableId == ledgerJournalTrans.tableId)
    {
        ledgerJournalTrans1 = _cursor;
    }
    if (ledgerJournalTrans.PaymMode == "RTGS" || ledgerJournalTrans.PaymMode == "NEFT")
    {
       ret = super(_cursor, _level, _triggerOffBody, _newPageBeforeBody);
    }
    return ret;
}