Sunday 16 August 2015

look up on table and calling it on form datasource

create a method on table like

public client static void lookupInvoiceDayOKN(FormStringControl _ctrl, PaymDayId _filter)
{
 
    // Intantiantes a SysTableLookup object telling it which control activated the lookup, and
    // what table should be displayed inside the lookup form.
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(PaymDay), _ctrl);

    Query query = new Query(); // This query will be used by the lookup form.
    QueryBuildDataSource qbds;

    ;

    // The "addLookupField" method adds the the fields that will be shown inside the lookup's grid.
    // The second, boolean parameter indicates that this field will be returned from the lookup when a
    // record is selected. In this case, we'll return our DummyPK.
    sysTableLookup.addLookupField(fieldnum(PaymDay, PaymDayId), true);
    //sysTableLookup.addLookupField(fieldnum(PaymDay, Field1));
    //sysTableLookup.addLookupField(fieldnum(PaymDay, Field2));
    //sysTableLookup.addLookupField(fieldnum(PaymDay, Field3));


    // Using our dummy table as a DataSource Table.
    qbds = query.addDataSource(tablenum(PaymDay));

    // This is the key part, what we want to filter to be displayed in the grid.
   // qbds.addRange(fieldnum(PaymDay, PaymDayId )).value(_filter);


    // Passes the query to the sysTableLookup.
    sysTableLookup.parmQuery(query);

    // Activates the lookup.
    sysTableLookup.performFormLookup();
}

then go the form data source of the field and then

over ride the look up method of the same and JUST CALL THE STATIC METHOD OF THAT TABLE LIKE

public void lookup(FormControl _formControl, str _filterStr)
{
    super(_formControl, _filterStr);
    SellingModelOKN::lookupInvoiceDayOKN(_formControl, "invoice day");
}


here we go our look up is ready......

but always try to create a look up by relation as it is more flexible...

No comments:

Post a Comment

intercompany PO multiple product receipt by x++

public void processStampICPO(PackingSlipId _deliveryNote,                             Transdate _deliverydate,                             ...