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;