Thursday, 3 November 2016

Button enable and disable in list page

public void selectionChanged()
{
    MG_CustTable mgCustTable;
    mgCustTable= this.listPage().activeRecord(queryDataSourceStr(MGCustListPage//(name of the query),custtable(query data source name)));

    super();

    if(mgCustTable.MG_Cust_Status == MG_Cust_Status::Active)
    {
        this.listPage().actionPaneControlEnabled(formControlStr(MGCustListPage(name of the from), Active(control name)), false);
        this.listPage().actionPaneControlEnabled(formControlStr(MGCustListPage, Inactive), true);

    }
    else if(mgCustTable.MG_Cust_Status == MG_Cust_Status::InActive)
    {
        this.listPage().actionPaneControlEnabled(formControlStr(MGCustListPage, Active), true);
        this.listPage().actionPaneControlEnabled(formControlStr(MGCustListPage, Inactive),false);

    }
}



===================================================================
active button:

void clicked()
{
    super();
    MG_CustTable.MG_Cust_Status = MG_Cust_Status::Active;
==================================================================
inactive:-

void clicked()
{
    super();
    MG_CustTable.MG_Cust_Status = MG_Cust_Status::InActive;
    MG_CustTable_ds.research(true);
}

Using args concept:-

Using args concept:-

Scenario:-getting selected customer detail by clicking button on projprojectContractListPage,customer detail should open on customer details form

To achieve above scenario:-
*first create a button on ProjProjectContract List Page in action button
and make that button Display Target to client,then override clicked method

void clicked()
{
    ProjFundingSource   projFunding;
    ProjInvoiceTable    projInvoice;

    CustTable   custtable;
    FormRun     formrun;
    Args    args = new Args();


    custtable = CustTable::find(ProjFundingSource::findCustAccount(ProjInvoiceTable.ProjInvoiceProjId).CustAccount);
    args.record(custtable);
    args.name(formStr(custtable));
    formRun = classFactory.formRunClass(args);
        formRun.init();
        formRun.run();
        formRun.wait();

}

Link of Args:-
https://calebmsdax.wordpress.com/2013/02/22/passing-parameters-between-forms-in-ax/




Calculate EmpExperienceusing Run Base batch

Form Path:- Human resources/Common/Workers/Workers:-
-------------------------------------------------------

if we edit any one worker record in that form another form should be open by clicking edit button.
there is a tab called Employeement tab in that we have
"Employeement Start Date and EmployeeMent End Date"
in that tab add  one more field called WorkerExperence field.

If Emp End Date = SystemDateToday() should not calculate Total expereance else calculate Total expereance.

To achieve this scenario we have to wor k on run base batch;-

duplicate the Tutorial_RunBaseBatch class:-

Tutorial_RunBaseBatch class--->Run()

ClassDeclaration:-

DialogField     dlgCustAccount;
    DialogField     dlgTransDate;
    HcmEmployment   employement;
    date             fromdate,todate;
;


Tutorial_RunBaseBatch class--->Run()
        ttsbegin;
        while select forupdate employement
        {
            fromdate = DateTimeUtil::date(employement.ValidFrom);
            todate = DateTimeUtil::date(employement.ValidTo);
            employement.ValidTimeStateUpdateMode (ValidTimeStateUpdate::Correction);

         if(todate!=today())
         {
            employement.EmployeeExperiance = -Global::yearDiff(fromdate,today());
            employement.update();
         }
          else if(todate <= today())
        {
            employement.EmployeeExperiance = 0;
            employement.update();

        }

        }
        ttscommit;

Thursday, 27 October 2016

dialog modifyfield -:
==================================================================================================
class declaration:-
------------------------------------------
class mahesh_ModifyDialogField extends RunBasebatch
{
    CustAccount CustId;

    DialogField dialogCustId;

    DialogField dialoglName;

    Dialog dialog;

}
==================================================================================================
Dialog:-
------------------------------------------
protected Object dialog()
{

    ;

    dialog = super();

    dialogCustId = dialog.addFieldValue(extendedTypeStr(CustAccount),"Customer","Customer");

    dialoglName = dialog.addFieldValue(extendedTypeStr(Name),"Name","Name");

    return dialog;
}
==================================================================================================
dialogPostRun()
--------------------------------------------------------
public void dialogPostRun(DialogRunbase tmpdialog)
{

    super(tmpdialog);

    tmpdialog.dialogForm().formRun().controlMethodOverload(true);

    tmpdialog.dialogForm().formRun().controlMethodOverloadObject(this);

}
==================================================================================================
filed_modified:-
-------------------------------------------------------
public boolean fld1_1_modified()
{

    FormStringControl control = dialog.formRun().controlCallingMethod();

    boolean isFieldModified;

    ;

    isFieldModified = control.modified();

    if(isFieldModified)

    {

    dialoglName.value(custTable::find(control.text()).Name());

    }

    return isFieldModified;

}
-------------------------------------------------------------------------------------------------------------------
main()
------------------------------------
static void main(Args args)
{

   mahesh_ModifyDialogField mah_ModifyDialogField = new mahesh_ModifyDialogField();

    ;

    if (mah_ModifyDialogField.prompt())
    {

    mah_ModifyDialogField.run();
    }

}
PO Inquiry
------------------------------
inqueiry using dynamic query:-

-----------------------------------------------------------------------------------------


init method:-
-----------------------------------------------------------------------------------------


public void init()
{
    super();
    delete_from M_purchTemp;
}


------------------------------------------------------------------------------------------



clicked method:-
-----------------------------------------------------------------------------------------
void clicked()
{
    Query query;
    QueryBuildDataSource qbds;
    QueryBuildRange qbr;
    QueryRun qr;
    void clicked()
{
    Query query;
    QueryBuildDataSource qbds;
    QueryBuildRange qbr,qbr1,qbr2;
    QueryRun qr;
    PurchTable purchTable;
    M_purchTemp obj;



    str var;
    str id;

    super();
    delete_from m_purchTemp;

        query   =   new query();
        qbds    =   Query.addDataSource(tableNum(purchTable));
        var     =   M_purchTemp_InvoiceAccount.valueStr();
        id      =   M_purchTemp_PurchId.valueStr();
   
        qbr     =   qbds.addRange(fieldNum(purchTable,invoiceAccount));
        qbr1    =   qbds.addRange(fieldNum(purchTable,PurchId));
        qbr2    =   qbds.addRange(fieldNum(purchTable,PurchStatus));
       
        qbr.value(var);
        qbr1.value(id);
        qbr2.value(queryValue(any2enum(M_purchTemp_PurchStatus1.selection())));

        qr=new QueryRun(query);
     while(qr.next())
     {
        purchTable            =     qr.get(tableNum(PurchTable));
        obj.InvoiceAccount    =     purchTable.InvoiceAccount;
        obj.VendGroup         =     purchTable.VendGroup;
        obj.Name              =     purchTable.PurchName;
        obj.DocumentStatus    =     purchTable.DocumentStatus;
        obj.PurchStatus       =     purchTable.PurchStatus;
        obj.PurchId           =     purchTable.PurchId;
        obj.insert();
    }

    M_purchTemp_ds.refresh();
     M_purchTemp_ds.research();
     //M_purchTemp_ds.reread();


}
public boolean validateField(FieldId _fieldIdToCheck)
{
    boolean ret;
    M_StudentTable stu;
    TextBuffer txt = new TextBuffer();
    str msg;
    //msg = this.Name;
    //txt.regularExpressions(true);
    //txt.Appendtext(this.name);
    //if(txt.find("^[A-Z]+$"))
    //{
        //stu.Name=this.Name;
    //}
    //else
//
        //throw error ("String contains only alphabets");
//
       ret = super(_fieldIdToCheck);
       if (ret)
       {
        switch (_fieldIdToCheck)
        {
            case fieldNum(M_StudentTable,Sub1):
            if(this.sub1 < 0)
            ret=checkFailed("Marks shoud not less than 0");

            else

            if(this.sub1 >50)
            ret=checkFailed("Marks shoud not exceed more than 50");
            break;

            case fieldNum(M_StudentTable,Sub2):
            if(this.sub2 < 0)
            ret=checkFailed("Marks shoud not less than 0");
            else

            if(this.Sub2 >50)
            ret=checkFailed("Marks shoud not exceed more than 50");
            break;

            case fieldNum(M_StudentTable,Name):
               msg = this.Name;
              // txt.regularExpressions(true);
               txt.Appendtext(this.name);
               if(txt.find("^[A-Z]+$"))
            {
                if(strLen(msg)<3)
                {
                   ret =checkFailed ("please enter more than 2 characters names");
                   break;
                }
                else
               stu.Name=this.Name;
            }
               else

                throw error ("Please Enter only alphabets");

                break;
           }
        }
           return ret;
        }
Date Formats in Reports:-

="From date: " & Format(First(Fields!Startdate.Value, "SKS_InvestmentDetails"),"MM/dd/yyyy")


="To date:" & Format(First(Fields!EndDate.Value, "SKS_InvestmentDetails"),"MM/dd/yyyy")
CustTable custtable;
    SalesTable salestable;
    MCustTable mcusttable;
    MSalesTable msalestable;
    CustTrans   custtrans;

    container ct;
    ct = ['USMF','DEMF'];


    //while select AccountNum from custtable
    //index hint AccountIdx
//{
    //info(strFmt("%1",custtable.AccountNum));
//}
//

    //while select  crossCompany : ct AccountNum from custtable
    //{
        //info(strFmt("%1 %2",custtable.dataAreaId,custtable.AccountNum));
    //}
    //
    info(custtable.dataAreaId);
    changeCompany ("DEMF")
    {
        custtable =null;
        while select AccountNum from CustTable
        {
        info(strFmt("%1 %2",custtable.AccountNum,custtable.dataAreaId));
        }
    }
    //ttsBegin;
    //while select forupdate MCustName from MCustTable
            //where mcusttable.MCustName == "abc"
    //{
        //mcusttable.MCustName = "ABC";
        //mcusttable.update();
        //info(strfmt("%1",mcusttable.McustName));
    //}
    //ttsCommit;

    //while select custtable order by CustGroup desc
    //{
        //info(strFmt("%1",custtable.CustGroup));
    //}


    //while select salestable order by CustAccount desc
    //{
        //info(strFmt("%1",salestable.CustAccount));
    //}

    //while select sum(CreditMax) from custtable where custtable.AccountNum == "US-040"
    //{
        //info(strFmt("%1 %2",custtable.AccountNum,custtable.CreditMax));
    //}

    //while select sum(CreditMax) from custtable order by CustGroup where custtable.CustGroup == "10"
    //{
        //info(strFmt("%1,%2",custtable.CustGroup,custtable.CreditMax));
    //}

    //while select sum(CreditMax) from custtable group by CustGroup order by CustGroup desc
    //{
        //info(strFmt("%1,%2",custtable.CustGroup,custtable.Creditmax));
    //}
//
    //info(strFmt("____________________"));
//
    //while select minof(AccountNum) from custtable
    //{
        //info(strFmt ("%1,%",custtable.AccountNum));
    //}
//
SalesOrder inquiry

public void init() //in data source level
{
    super();
    delete_from M_SalesTemp;
}
------------------------------------------------------------------------------------
void clicked()
{
    SalesTable salesTable;
    M_SalesTemp obj;
    SalesStatus salesStatus;
    CustAccount custAccount;
    super();

    delete_from M_SalesTemp;

    custAccount = M_SalesTemp_CustAccount1.valueStr();
    salesStatus = M_SalesTemp_SalesStatus1.selection();
     if (custAccount&&salesStatus)
    {
        ttsBegin;
        while select salesTable where salesTable.CustAccount == custAccount
                && salesTable.SalesStatus == salesStatus
        {
                obj.SalesId         =   salesTable.SalesId;
                obj.CustAccount     =   salesTable.CustAccount;
                obj.CustGroup       =   salesTable.CustGroup;
                obj.SalesStatus     =   salesTable.SalesStatus;
                obj.DocumentStatus  =   salesTable.DocumentStatus;
                obj.DeloveryDate    =   salesTable.DeliveryDate;
                obj.insert();
        }
        ttsCommit;
    }

        else if(custAccount)
    {
        ttsBegin;
        while select salesTable where
                salesTable.CustAccount == custAccount
        {
                obj.SalesId         =   salesTable.SalesId;
                obj.CustAccount     =   salesTable.CustAccount;
                obj.CustGroup       =   salesTable.CustGroup;
                obj.SalesStatus     =   salesTable.SalesStatus;
                obj.DocumentStatus  =   salesTable.DocumentStatus;
                obj.DeloveryDate    =   salesTable.DeliveryDate;
                obj.insert();
        }
        ttsCommit;
    }
        else if (salesStatus)
    {
        ttsBegin;
        while select salesTable where
                salesTable.SalesStatus == salesStatus
        {
                obj.SalesId         =   salesTable.SalesId;
                obj.CustAccount     =   salesTable.CustAccount;
                obj.CustGroup       =   salesTable.CustGroup;
                obj.SalesStatus     =   salesTable.SalesStatus;
                obj.DocumentStatus  =   salesTable.DocumentStatus;
                obj.DeloveryDate    =   salesTable.DeliveryDate;
                obj.insert();
        }
        ttsCommit;
    }

    M_SalesTemp_ds.refresh();
    M_SalesTemp_ds.research();

    }
Dynamic Query For Sales Inquiry from 3 tables:-
=======================================================================================================================================
void clicked()
{
    Query query;
    QueryBuildDataSource qbds,qbds1,qbds2;
    QueryBuildRange qbr,qbr1,qbr2;
    QueryRun qr;
    str i,s,s1;
    SalesTable  salestab;
    SalesLine   salesnum;
    InventDim   dim;
    SalesTest   test;

    super();

    delete_from SalesTest;

    s       =  CustAccount.valueStr();
    i       =  CustGroupId.valueStr();
    s1      =  Itemid.valueStr();

    query   =   new query();
    qbds    =   Query.addDataSource(tableNum(SalesTable));
    qbr     =   qbds.addRange(fieldNum(SalesTable,CustAccount));
    qbr2    =   qbds.addRange(fieldNum(SalesTable,custgroup));

    qbds1   =   qbds.addDataSource(tableNum(SalesLine));
    qbr1    =   qbds1.addRange(fieldNum(SalesLine,ItemId));
    qbds1.relations(true);

    qbds2   =   qbds1.addDataSource(tableNum(InventDim));
    qbds2.relations(true);
    if(s)
        qbr.value(s);
    if(i)
        qbr2.value(i);
    if(s1)
        qbr1.value(s1);

    qr=new QueryRun(query);

    while(qr.next())
    {
    salestab        =  qr.get(tableNum(SalesTable));
    dim             =  qr.get(tableNum(InventDim));
    salesnum        =  qr.get(tableNum(SalesLine));

    SalesTest.Salesid    =   salestab.SalesId;
    SalesTest.Itemid     =   salesnum.ItemId;
    SalesTest.Site       =   dim.InventSiteId;
    SalesTest.Warehouse  =   dim.InventLocationId;
    SalesTest.Custgroup  =   salesnum.CustGroup;
    SalesTest.CustAccount =  salesnum.CustAccount;
    SalesTest.CustName   =   salesnum.Name;
    SalesTest.insert();
    }

    SalesTest_ds.refresh();
    SalesTest_ds.research();
}


public void selectionChanged()
{
    MG_CustTable mgCustTable;
    mgCustTable= this.listPage().activeRecord(queryDataSourceStr(MGCustListPage//(name of the query),custtable(query data source name)));

    super();

    if(mgCustTable.MG_Cust_Status == MG_Cust_Status::Active)
    {
        this.listPage().actionPaneControlEnabled(formControlStr(MGCustListPage(name of the from), Active(control name)), false);
        this.listPage().actionPaneControlEnabled(formControlStr(MGCustListPage, Inactive), true);

    }
    else if(mgCustTable.MG_Cust_Status == MG_Cust_Status::InActive)
    {
        this.listPage().actionPaneControlEnabled(formControlStr(MGCustListPage, Active), true);
        this.listPage().actionPaneControlEnabled(formControlStr(MGCustListPage, Inactive),false);

    }

}
adding image to the product:-
======================================================================
static void M_insertimage(Args _args)
{
    DocuActionArchive               docuActionArchive;
    EcoResProductImageManagement    productImageManagement;
    EcoResProductImageThumbnail     ecoResProductImageThumbnail;
    DocuRef                         docuRef;
    DocuValue                       docuValue;
    EcoResProductImage              ecoResProductImage;
    InventTable                     inventTable;
// Specify the display product number

    InventTable = InventTable::find("Mshirt-50");
    ttsBegin;
    docuRef.TypeId     = "File";
    docuRef.RefTableId = inventTable.TableId;
    docuRef.RefRecId   = InventTable.RecId;
    docuRef.RefCompanyId = inventTable.dataAreaId;
    docuRef.ActualCompanyId = curext();
    docuRef.insert();
    docuActionArchive = DocuAction::newDocuRef(docuRef);
    docuActionArchive.add(docuRef,"C:\\Users\\maheshgoud.g\\Desktop\\shirt.jpg");

    ecoResProductImage.RefRecId         = docuRef.RecId;
    ecoResProductImage.RefRecord        = docuRef.RefRecId;
    ecoResProductImage.ImageFormat      = 'jpg';
    ecoResProductImage.FileName         = "shirt.jpg";
    ecoResProductImage.Usage            = EcoResProductImageUsage::External;
    ecoResProductImageThumbnail         = new EcoResProductImageThumbnail(false);
    ecoResProductImage.MediumSize       = ecoResProductImageThumbnail.generateThumbnail(204,204,docuRef);
    ecoResProductImage.ThumbnailSize    = ecoResProductImageThumbnail.generateThumbnail(48,48,docuRef);

    if (ecoResProductImage.MediumSize == connull())
    {
        info("@SYS301935");
    }

======================================================================

create the  temp folder in c drive with USMF/Organization administration/Area page/documenttype/file

======================================================================
  
Comment all the code:

Comment all the code with Ctrl+E+C with shortcut (Or) Select your code right click and go to the
Scripts -> comments-> comment -> click on that you will get your code commented with the help of below code add this method in the EditorScripts class after that test it.

Public void comments_comment(Editor _editor)
{
    int startLine = _editor.selectionStartLine();
    int endLine   = _editor.selectionEndLine();
    int i;
    #define.comment('//')

    _editor.unmark();
    for (i = startLine; i <= endLine; i++)
    {
        _editor.gotoLine(i);
        _editor.gotoCol(1);
        _editor.insertString(#comment);
    }
}

Un-Comment all the code:

UnComment all the code with Ctrl+E+U with shortcut (Or) Select your code right click and go to the
Scripts -> comments-> uncomment -> click on that you will get your code commented with the help of below code add this method in the EditorScripts class after that test it.

public void comments_uncomment(Editor _editor)
{
    int startLine = _editor.selectionStartLine();
    int endLine   = _editor.selectionEndLine();
    int i, col;
    str line;
    #define.comment('//')

    _editor.unmark();
    for (i = startLine; i <= endLine; i++)
    {
        _editor.gotoLine(i);
        _editor.gotoCol(1);

        line = _editor.currentLine();

        // Skip leading white space
        for (col = 1; col <= strlen(line); col++)
        {
            if (substr(line, col, 1) != ' ')
            {
                if (substr(line, col, strlen(#comment)) == #comment)
                {
                    _editor.gotoCol(col);
                    _editor.deleteChars(strlen(#comment));
                }
                break;
            }
        }
    }
}

 Insert Hader comments:

Add below method on the EditorScripts class: 

public void comments_insertHeader(Editor e)
{
    e.unmark();
    e.gotoLine(1);
    e.gotoCol(1);

    e.insertLines('// Changed on ' + date2str(today(),123,2,1,3,1,4, DateFlags::FormatAll ) + ' at ' + time2str(timenow(), 11) + ' by ' + curuserid()'\n');

}
For Testing Go to the new jobs right click Scripts -> comments-> InsertHeader -> click on that you will get comment on your code header side.

Start comments:

Add below method on this class EditorScripts , and test in the job

public void comments_Started(Editor _editor)
{
    int startLine = _editor.selectionStartLine();
    int endLine   = _editor.selectionEndLine();
    int i;
   // #define.comment('//')

    _editor.unmark();
    for (i = startLine; i <= endLine; i++)
    {
        _editor.gotoLine(i);
        _editor.gotoCol(1);
        //_editor.insertString(#comment);
        _editor.insertLines('// Changes started on ' + date2str(today(),123,2,1,3,1,4, DateFlags::FormatAll ) + ' at ' + time2str(timenow(), 1, 1) + ' by ' + curuserid() +'\n');
    }
}

End comments:-

Add below method on this class EditorScripts , and test in the job

public void comments_END(Editor _editor)
{
    int startLine = _editor.selectionStartLine();
    int endLine   = _editor.selectionEndLine();
    int i;
   // #define.comment('//')

    _editor.unmark();
    for (i = startLine; i <= endLine; i++)
    {
        _editor.gotoLine(i);
        _editor.gotoCol(1);
        //_editor.insertString(#comment);
        _editor.insertLines('// Changes End on ' + date2str(today(),123,2,1,3,1,4, DateFlags::FormatAll ) + ' at ' + time2str(timenow(), 11) + ' by ' + curuserid() + '\n');
    }
}


http://stackoverflow.com/questions/27923749/how-to-fix-number-of-blank-rows-in-ssrs

https://sumitsaxfactor.wordpress.com/2012/07/14/create-project-tool-for-developers-ax-2012/


Create Project Contract through X++

ProjFundingSource   projFundingSource;
    NumberSeq           numSeq;
    CustTable           custtable;


    ;

        ttsBegin;
        projInvoiceTable.clear();
        projInvoiceTable.initValue();

        custTable                           = CustTable::find("Give your account number");
        numSeq = NumberSeq::newGetNum(projParameters::numRefProjInvoiceProjId(), true, true);
        projinvoiceTable.ProjInvoiceProjId  =  numSeq.num();


        projInvoiceTable.CurrencyId         = "USD";
        projinvoiceTable.Description        = custTable.name();

        this.parmprojectcontract(projinvoiceTable.ProjInvoiceProjId);

        projInvoiceTable.insert();


        projFundingSource.ContractId        = projInvoiceTable.ProjInvoiceProjId;

        projFundingSource.CustAccount       = "Account number";
        projFundingSource.FundingSourceId   = CustTable.name();
        projFundingSource.FundingType       = ProjFundingType::Customer;
        projFundingSource.PaymentTermsId    = "Net8";
        projFundingSource.PaymentscheduleId = paymentform;
        projFundingSource.editProjFunder(true,projFundingSource.CustAccount);


     

        projFundingSource.insert();

        projFundingRule::createDefaultFundingRule(projInvoiceTable.ProjInvoiceProjId,projInvoiceTable.RecId);


        ttsCommit;
inquiry by using execute query

In form level in class :-
class declaration:-

public class FormRun extends ObjectRun
{
    QueryBuildRange qbr;
}

--------------------------------------------------------------------------------------------------------------
Execute query method in data source level:-


public void executeQuery()
{
    qbr.value(PurchTable_VendGroup.valueStr());
    qbr.value(PurchTable_InvoiceAccount.valueStr());
    super();
}

-------------------------------------------------------------------------------------------------------------
Init method in datasource level:-

public void init()
{
    super();
    qbr=this.query().dataSourceName("PurchTable").addRange(fieldNum(PurchTable,VendGroup));
    qbr=this.query().dataSourceName("PurchTable").addRange(fieldNum(PurchTable,InvoiceAccount));
}

---------------------------------------------------------------------------------------------------------------
CLicked method on Button in Design level:-

void clicked()
{
    super();

    PurchTable_ds.executeQuery();

}
Dynamic Query Example;-

Dynamic Aggregate Functions
=================================================================
static void dynamicselectaggregate(Args _args)
{
    MCustTable mCustTable;
    Query query;
    QueryBuildDataSource qbds;
    QueryBuildRange qbr;
    QueryRun qr;

    query = new query();
    qbds = query.addDataSource(Tablenum(mCustTable));
    //qbds.addSelectionField(fieldNum(mCustTable,MPRId),SelectionField::sum);
   // qbds.addSelectionField(fieldNum(mCustTable,MPRId),SelectionField::Avg);
    //qbds.addSelectionField(fieldNum(mCustTable,MPRId),SelectionField::Max);
    //qbds.addSelectionField(fieldNum(mCustTable,MPRId),SelectionField::Min);
    //qbds.addSelectionField(fieldNum(mCustTable,MPRId),SelectionField::Count);
   // qbds.addSelectionField(fieldNum(mCustTable,MPRId),SelectionField::Database);

   //qbds.addSelectionField(fieldNum(mCustTable,MPRId),SelectionField::ComputedColumn);
    //qbds.addGroupByField(fieldNum(mCustTable,MSid));
    //qbr=qbds.addRange(fieldNum(mCustTable,MSid));
    //qbr.value("100..200");
    qr = new QueryRun(query);
=======================================================================
Dynamic Joins:-
==============================================
static void dynamicjoin(Args _args)
{
    MCustTable              mCustTable;
    MSalesTable             mSalesTable;
    Query                   query;
    QueryBuildDataSource    qbds1,qbds2;
    QueryBuildRange         qbr;
    QueryRun                qr;


    query = new query();
    qbds1 = query.addDataSource(tableNum(mCustTable));
    //qbds1.addRange(fieldNum(mCustTable,MSid));
    qbds2= qbds1.addDataSource(tableNum(mSalesTable));
    //qbds2.joinMode(JoinMode::InnerJoin);
   // qbds2.joinMode(JoinMode::OuterJoin);
    //qbds2.joinMode(JoinMode::ExistsJoin);
    qbds2.joinMode(JoinMode::NoExistsJoin);
   
    qbds2.relations(true);
    qr = new QueryRun(query);

    while (qr.next())
    {
        mSalesTable = qr.get(tableNum(mSalesTable));
        info(strFmt("%1",mSalesTable.MSId));
    }

}
========================================================================
Dynamic Query:-
-------------------------------------------------------------------------------------------------

static void CopyDynamicsQueryEx(Args _args)
{
    Query query;
    QueryBuildDataSource    qbds,qbds1;
    QueryBuildRange qbr, qbrAccNO;
    QueryRun    qr;
    CustTable       custtable;

    query = new query();
    qbds = query.addDataSource(tableNum(CustTable));
    qbds1=query.addDataSource(tableNum(SalesTable));
    qbds.addOrderByField(fieldNum(custtable,AccountNum), SortOrder::Descending);
    qbr = qbds.addRange(fieldNum(CustTable,CustGroup));
   // qbr.value("10");

   // qbrAccNO = qbds.addRange(fieldNum(CustTable,CreatedDateTime));
   // qbrAccNO.value(queryRange("1/4/2009","1/6/2009"));
    qr = new QueryRun(query);
    while(qr.next())
    {
        custtable = qr.get(tableNum(CustTable));
        info(strFmt("%1 - %2 - %3", custtable.AccountNum,custtable.CustGroup,custtable.createdDateTime));
    }
}
===================================================================
Select Statements Using Dynamic Query:-
===========================================================
static void dynamicselectex(Args _args)
{
    MCustTable              mCustTable;
    Query                   query;
    QueryBuildDataSource    qbds;
    QueryBuildRange         qbr;
    QueryRun                qr;

    query= new query();
    qbds = query.addDataSource(tableNum(MCustTable));
   // qbds.addOrderByField(fieldNum(mCustTable,MSId),SortOrder::Descending);
    qbds.addOrderByField(fieldNum(mCustTable,MCustName),SortOrder::Descending);
    //qbds.firstOnly(true);
    //qbds.firstFast(true);
    //qbds.update(true);
    qbr =qbds.addRange(fieldNum(mCustTable,MCustName));
    //qbr.value("abc");

    qr = new QueryRun(query);

    while (qr.next())
    {
        mCustTable = qr.get(tableNum(mCustTable));
        info(strFmt("%1 %2",mCustTable.MCustName,mCustTable.MSid));
    }


}

=============================================================
Joins Examples:-- 06-04-2016
--------------------------------------------------------------------------------------

static void M_joinsEx(Args _args)
{
    MCustTable mCustTable;
    MSalesTable mSalesTable;
    MPurchTable mPurchTable;

    while select mSalesTable join mCustTable
            where mSalesTable.MSId == mCustTable.MSid
    {
        info(strFmt("%1,%2",mSalesTable.MSId,mCustTable.MSid));
    }
   
    while select mCustTable join mSalesTable
            where mCustTable.MCustName == mSalesTable.MCustName
    {
        info(strFmt("%1,%2",mCustTable.MCustName,mSalesTable.MCustName));
    }

    while select mSalesTable outer join mCustTable
            where mSalesTable.MSId == mCustTable.MPRId
    {
        info(strfmt("%1,%2",mSalesTable.MSId,mCustTable.MPRId));

    }
   
    while select mSalesTable outer join mCustTable
            where mSalesTable.MCustName == mCustTable.MCustName
    {
        info(strFmt("%1,%2",mSalesTable.MCustName,mCustTable.MCustName));
    }
       
    while select mCustTable exists join  mPurchTable
            where mCustTable.MCustName == mPurchTable.MCustName
    {
        info(strFmt("%1,%2",mCustTable.MCustName,mPurchTable.MCustName));
    }
   
        while select mCustTable notexists join mPurchTable
              where mCustTable.MCustName == mPurchTable.MCustName
    {
        info(strFmt("%1,%2",mCustTable.MCustName,mPurchTable.MCustName));
    }
       
   

}
========================================================================
dynamicquery examplesss
--------------------------------------------------------------------------

static void dynamicqueryExmp1(Args _args)
{
    Query query;
    QueryBuildDataSource qbds;
    QueryBuildRange qbr;
    QueryRun qr;
    MCustTable mcusttable;

    query   = new query();
    qbds    = query.addDataSource(tableNum(MCustTable));
   // qbr     =qbds.addRange(fieldNum(MCustTable,MPRId));
   // qbr     = qbds.addRange(fieldNum(MCustTable,MSId));
    qbr     = qbds.addRange(fieldNum(MCustTable,MCustName));
    qbds.addOrderByField(fieldNum(MCustTable,MSId),SortOrder :: Descending);
    qbds.addOrderByField(fieldNum(MCustTable,MCID),SortOrder ::Descending);
    qbr.value(queryRange("1","1000"));
    qbr.value("a*");


    //qbds.addGroupByField(fieldNum(mcusttable,MSId));
    qr      = new QueryRun(query);
    while (qr.next())
    {
        mcusttable = qr.get(tableNum(MCustTable));
        info(strFmt("MCId - %1, McustName - %2, MSId - %3, MPRId - %4",mcusttable.MCId,mcusttable.MCustName,mcusttable.MSId,mcusttable.MPRId));
    }

}
================================================================
Multi DATA Source in Dynamic query
===============================================================
Query                                    query = new Query();
    QueryBuildDataSource     queryBuildDSSalesTable;
    QueryBuildDataSource     queryBuildDSSalesLine;
    QueryBuildRange              queryBuildRange;
    QueryRun                            queryRun;
    SalesLine                            salesLine;
    ;
    
    // Setup the primary datasource.
    queryBuildDSSalesTable  = query.addDataSource(tablenum(SalesTable));
    queryBuildDSSalesTable.addRange(fieldnum(SalesTable,SalesId)).value('XXXXXX');

    // Setup the secondary (joined) datasource.
    queryBuildDSSalesLine   = queryBuildDSSalesTable.addDataSource(tablenum(SalesLine));
    queryBuildDSSalesLine.joinMode(JoinMode::InnerJoin);
    queryBuildDSSalesLine.relations(true);
    queryRun = new QueryRun(query);
    while(queryRun.next())
    {
        salesLine   = queryRun.get(tablenum(SalesLine));
        info(strfmt('%1',salesLine.SalesId));
    }