Contact Me

Total Pageviews

Monday 11 August 2014

Lookup on Form Control Using Temporary Tables in Axapta

Create lookup using temporary table. Populate the temporary table with the required data in the init() method of the form.In the below example, the Tmpcontactperson table can populated with required data and the lookup called using the code below.

public void lookup()
{
    //insert record into temporary table in the init() method of the form
    sysTableLookup = SysTableLookup::newParameters(tableNum(Tmpcontactperson),this,false );
    sysTableLookup.addLookupField(fieldNum(Tmpcontactperson, ContactPersonId),True); sysTableLookup.addLookupField(fieldNum(Tmpcontactperson, CustAccount),false);
    sysTableLookup.addLookupField(fieldNum(Tmpcontactperson, Name),False);
    sysTableLookup.addLookupField(fieldNum(Tmpcontactperson, Email),False);
    sysTableLookup.addLookupField(fieldNum(Tmpcontactperson, Function),false);
    
sysTableLookup.parmTmpBuffer(tmpContactPerson); // Gets or sets the TmpBuffer
    sysTableLookup.performFormLookup();

}


In the classdeclaration method of the form declare the buffer of the Temporary Table

public class FormRun extends ObjectRun
{
  
    TmpContactPerson            tmpcontactperson;

}

Override the Init() method of the form and insert data into the Temporary Table.

   ContactPerson         contactperson;
    ;
    while select contactperson where contactperson.Name == "Robert Hernady"
    {
      tmpcontactperson.ContactPersonId = contactperson.ContactPersonId;
      tmpcontactperson.Name = contactperson.Name;
      tmpcontactperson.Email = contactperson.Email;
      tmpcontactperson.Function =contactperson.Function;
      tmpcontactperson.CustAccount = contactperson.CustAccount;
      tmpcontactperson.doInsert();

    }

Happy Daxing:)

No comments:

Post a Comment