mercredi 2 février 2011

How to override the lookup method of a field to display a list of values

In the Class SysLookup add this method :

public static client void lookupList(FormStringControl _formStringControl, List _valueList, str _columnLabel = '')
{
    Args    args;
    FormRun formRun;
    ;
    if (_formStringControl && _valueList && _valueList.typeId() == Types::String)
    {
        args = new Args(formstr(SysLookup));
        args.parmObject(_valueList);
        args.parm(_columnLabel);

        formRun = classFactory.formRunClass(args);
        _formStringControl.performFormLookup(formRun);
    }
}

then in the lookup method of your field use this method for example:

public void lookup()
{
   VendTable    VendTable;
   string30   x;
   int        i=0;
   DirEcommunicationAddress DirEcommunicationAddress;
   DirPartyECommunicationRelationship   DirPartyECommunicationRelationship;
   List    valueList = new List(Types::String);

   ;
   super();

   select firstOnly PartyId from VendTable where VendTable.AccountNum == PurchTable.OrderAccount ;
   while select ValuesRecId from DirPartyECommunicationRelationship
                where DirPartyECommunicationRelationship.PartyId == VendTable.PartyId
                {
                    select phone from DirEcommunicationAddress where DirEcommunicationAddress.RecId
                           == DirPartyECommunicationRelationship.ValuesRecId;

                    if (DirEcommunicationAddress.Phone != "")
                    {
                        valueList.addEnd(DirEcommunicationAddress.Phone);
                        i++;
                    }

                }
   if(i>0)
   {
        SysLookup::lookupList(this, valueList, "Phones");
   }
}


See Also this method

public void lookup(FormControl _formControl, str _filterStr)
{
    SysTableLookup sysTableLookup; // systemclass to create //customlookup
    Query query;
    QueryBuildDataSource qbd;

    ;
    sysTableLookup = SysTableLookup::newParameters(
    tablenum(InventTable),
    _formcontrol);

    // Construct query on the table,
    // whose records you want to show as lookup.
    query = new Query();
    qbd = query.addDataSource(tablenum(InventTable));
    qbd.addRange(fieldnum(InventTable,ItemType)).value(SysQuery::value(enum2str
    (ItemType::Item)));

    // add the fields to the lookup list
    sysTableLookup.addLookupfield(fieldnum(InventTable,ItemId));
    sysTableLookup.addLookupfield(fieldnum(InventTable,ItemName));

    // pass the query as parameter
    // system will show the records in the lookup
    // as per your query
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();

}



Happy Daxing!

Aucun commentaire:

Enregistrer un commentaire