Tuesday, 24 December 2013

Based on Company salesid has to change through X++ in ax 2012

class SalesIdLookup extends RunBase
{
   FormStringControl    companyIdCtrl,salesIdCtrl;
}

protected Object dialog(DialogRunbase dialog, boolean forceOnClient)
{
    DialogRunBase dialogRunBase;
    ;
    dialogRunBase = super(dialog, forceOnClient);

    companyIdCtrl = dialogRunBase.formBuildDesign().addControl(FormControlType::String,"CompanyId");
    companyIdCtrl.extendedDataType(71);

    salesIdCtrl = dialogRunBase.formBuildDesign().addControl(FormControlType::String,"SalesId");
    salesIdCtrl.extendedDataType(473);
    return dialogRunBase;
}

public void dialogPostRun(DialogRunbase dialog)
{
    ;
    super(dialog);
    dialog.dialogForm().formRun().controlMethodOverload(true);
    dialog.dialogForm().formRun().controlMethodOverloadObject(this);

    companyIdCtrl = dialog.dialogForm().formRun().design().controlName("CompanyIdCtrl");
    salesIdCtrl   = dialog.dialogForm().formRun().design().controlName("salesIdCtrl");
}

public container pack()
{
    return connull();
}

void salesIdLookup()
{
    Query               query = new Query();
    SysTableLookup      sysTableLookup = SysTableLookup::newParameters(      tablenum(SalesTable),salesIdCtrl);
    ;

    sysTableLookup.addLookupfield(fieldNum(SalesTable,SalesId));
    sysTableLookup.addLookupfield(fieldNum(SalesTable,SalesName));

    query.addDataSource(tableNum(SalesTable));
    query.allowCrossCompany(true);
    query.addCompanyRange(companyIdCtrl.text());

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

public boolean unpack(container packedClass)
{
    return true;
}

public static void main(Args args)
{
    SalesIdLookup   sil = new SalesIdLookup();
    ;

    if(sil.prompt())
    {
        sil.run();
    }
}

-------------------------------------------------------------------------
class SamSelectiveLookup extends RunBase
{
    FormStringControl   custGroupCtrl, customerCtrl;
}

protected Object dialog()
{
    DialogRunBase ret;

    ret = super();

    custGroupCtrl = ret.formBuildDesign().addControl(FormControlType::String, 'ComapnyId');
    custGroupCtrl.extendedDataType(71);

    customerCtrl = ret.formBuildDesign().addControl(FormControlType::String, 'purchid');
    customerCtrl.extendedDataType(473);

    return ret;
}

public void dialogPostRun(DialogRunbase dialog)
{
    super(dialog);

    dialog.dialogForm().formRun().controlMethodOverload(true);
    dialog.dialogForm().formRun().controlMethodOverloadObject(this);

    custGroupCtrl = dialog.dialogForm().formRun().design().controlName('ComapnyId');
    customerCtrl = dialog.dialogForm().formRun().design().controlName('PurchId');
}

public container pack()
{
    return conNull();
}

void PurchId_lookup()
{
    Query                   query          = new Query();
    SysTableLookup          sysTableLookup = SysTableLookup::newParameters(tableNum(SalesTable), customerCtrl);
    ;

    sysTableLookup.addLookupField(fieldNum(SalesTable, SalesId));
    sysTableLookup.addLookupField(fieldNum(SalesTable,SalesName ));

    query.addDataSource(tableNum(SalesTable));
    query.allowCrossCompany(true);
    query.addCompanyRange(custGroupCtrl.text());

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

public boolean unpack(container packedClass)
{
    return true;
}

static void main(Args _args)
{
    SamSelectiveLookup test1 = new SamSelectiveLookup();
    ;

    if (test1.prompt())
    {
        test1.run();
    }
}

No comments:

Post a Comment