Translate

Wednesday, July 27, 2011

Lookup() Method

Implement this code in the lookup() method of the field where you need the lookup to be displayed.

NS: The same code can be written in three places to achieve the lookup.
1) Under AOT->Table->Method and cal this method from the form design where you want to display the lookup.
2) Form->Datasource->Table->Field->method
3) Form->Design->Field->Method.

public void lookup()
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource QbdsJoin;

// Instantiate sysTableLookup object using table which will provide the visible fields
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(TableName), this);
;

// Create the query.
qbds= query.addDataSource(tableNum(TableName));
qbds.addRange(fieldNum(TableName, FieldName)).value('Value');

//Join Table
QbdsJoin= qbds.addDataSource(tableNum(TableName2));
QbdsJoin.relations(true);
QbdsJoin.joinMode(JoinMode::ExistsJoin);
QbdsJoin.addRange(fieldNum(TableName2, Fieldname)).value('Value');

// Set the query to be used by the lookup form
sysTableLookup.parmQuery(query);

// Specify the fields to show in the form.
sysTableLookup.addLookupfield(fieldNum(TableName, FiledName));
sysTableLookup.addLookupfield(fieldId2Ext(fieldNum(TableName, Dimension), 1));

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

7 comments:

  1. You have made some good points there. I checked on the net to
    find out more about the issue and found most individuals
    will go allong with your views on this site.

    Review my web-site: solar panels for home

    ReplyDelete
  2. I was able to find good advice from your articles.

    Visit my web page :: latest games on iphone

    ReplyDelete
  3. variable this has not been declared error

    // Instantiate sysTableLookup object using table which will provide the visible fields
    SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(TableName), this);

    ReplyDelete
  4. Hi,,
    Replace 'TableName' with the actual table which you are looking for lookup.

    Thanks,
    Prasan

    ReplyDelete
    Replies
    1. done that ..but i tried to write it in table level then 'this' error come up.

      but in form level its working.

      Thanks for the tutorial Sir..

      Delete
    2. Ah!! yes,

      If you are writing that in table level, then that method should have a parameter of type FormControl, then use this form control's variable there instead 'this'.
      while invoking this method send that formcontrol to this method as parameter

      Delete