LookUp value from Multiple Companies

Hi guys , Its really good to use multiple Company Datas in Lookup.

Here i have designed for this solution..

1.Created one New Tabled called SaadLookpUp. which contains the field of String Data Type which EDT as Name
2. Created one New Form called SaadMultiCompLookUp. here i have used this form for bulding LookUp
added new datasource with the Table of SaadLookpUp and set CrossCompanyAutoQuery to Yes.
More Reference for creating Form_LookuP
3. Created one new EDT called SaadMultiCompLookUp and set FormHelp to SaadMultiCompLookUp

4. Created another Form called SaadOutputMultiComp , in this form i have shown two way of retrieving Names,  one way is showing All Company Names and another way is  showing Names from the selected Company. .
Created one String Control in Design node of this form called Name and set ExtendedDataType as SaadMultiCompLookUp.

5. Created another String Control called Company by this Control we have to show the company Name and Override lookUp()

public void lookup()
 {;
 //super();
 SaadMultiComLookUp::DataArea(this);
 }

Created one Class called SaadMultiComLookUp
here i have Created one Static method named as DataArea() for Accessing Company Name in LookUp

static void DataArea(FormControl _formControl)
 {
 SysTableLookUp lookUp;
 ;
lookUp = SysTableLookUp::newParameters(tablenum(DataArea), _formControl); //
 lookUp.addLookupfield(fieldnum(DataArea, Id));
 lookUp.addLookupfield(fieldnum(DataArea, Name));
 lookup.performFormLookup();
 }

Same way i have created another String Control called Name1 and override lookUp()

public void lookup()
 {;
 //super();
 SaadMultiComLookUp::CompanyWiseNames(Company);
 }

here created another one static Method in CompanyWiseNames() in SaadMultiComLookUp Class for Accessing Lookup names Based on the Selected Company .

static void CompanyWiseNames(FormControl _formControl)
  {
  SysTableLookUp lookUp;
  Query Q = new Query();
  QueryBuildDataSource Qbds;
  QueryBuildRange Qbr;
  ;
lookUp = SysTableLookup::newParameters(tablenum(SaadLookpUp), _formControl);
  lookUp.addLookupfield(fieldnum(SaadLookpUp, Name));
Q.allowCrossCompany(true);
  Q.addCompanyRange(_formControl.valueStr());
  Qbds = Q.addDataSource(tablenum(SaadLookpUp));
lookUp.parmQuery(Q);
  lookUp.performFormLookup();
  }

6. Add the Records in SaadLookUp Table in different Company.
Comp1 Comp2

7. Open the Form SaadOutputMultiComp
So this is the final Result…

Result1 Result2 Result3

Download this XPO
Hope You Enjoyed …. 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s