How to multiselect lookup using Dialog box

Hi,

I have created lookup using the following code and the output for the code is also given below. here I able to select only one record at a time in the lookup field. but I want to select multiple values in the single lookup field based on I want to get the values.

class CustCreateDialog1 extends RunBaseBatch
{
    DialogField fieldAccount,fieldAccount1,fieldAccount2,fieldAccount3;
    DialogFIeld fieldName;

    CustTable   custTable;
    CustAccount custAccount;
    DirPartyName    dirPartyName;
    ItemId      itemId;
    SysLookupMultiSelectCtrl    msCtrl;


        QueryRun                    queryRun;

    FormStringControl           fsc;
    FormBuildControl            fbc;
    FormBuildStringControl      fbsc;
}

protected Object Dialog()
{
    //FormRun         fr;
    Dialog dialog;
    ;
    //fr = dialog.dialogForm().formRun();
    dialog = super();

    // Set a title for dialog
    dialog.caption( 'Simple Dialog');

    // Add a new field to Dialog
    fieldAccount = dialog.addField( extendedTypeStr(CustAccount), 'Customer account' );
    fieldAccount1=dialog.addField( extendedTypeStr(ItemId), 'Item Id' );
    fieldAccount2=dialog.addField( extendedTypeStr(DirPartyName), 'Vendor Name' );
     fieldAccount2=dialog.addField( extendedTypeStr(DirPartyName), 'Vendor Name' );
  // msCtrl = SysLookupMultiSelectCtrl::construct(element, TestCtrl, querystr(StudentCourse));
   // sysms = SysLookupMultiSelectCtrl::construct(fr, Fr.design().control(fieldAccount, queryStr(VT_UserInfoQuery));


    return dialog;
}

public boolean getFromDialog()
{
    // Retrieve values from Dialog
    custAccount = fieldAccount.value();
    ItemId=fieldaccount1.value();
   dirPartyName =fieldaccount2.value();


    return super();
}

public static void main(Args _args)
{
    CustCreateDialog1 custCreate = new CustCreateDialog1();

    // Prompt the dialog, if user clicks in OK it returns true
    if (custCreate.prompt())
    {
        custCreate.run();
    }
}

public void run()
{
      SysExcelApplication  xlsApplication;
   SysExcelWorkBooks    xlsWorkBookCollection;
   SysExcelWorkBook     xlsWorkBook;
   SysExcelWorkSheets   xlsWorkSheetCollection;
   SysExcelWorkSheet    xlsWorkSheet;
   SysExcelRange        xlsRange;
   //CustTable            custTable;
   int                  row = 1;
   str                  fileName;
    DirPartyTable       dirPartyTable;
    InventTable         inventTable;
   ;
    // Set Dialog field value to find CustTable
    //custTable = CustTable::find(custAccount);

    if (custAccount)
    {
        // Shows retrieved information


   //Filename
   fileName = "C:\\Test.xlsx";
   //Initialize Excel instance
   xlsApplication           = SysExcelApplication::construct();
   //Open Excel document
   //xlsApplication.visible(true);
   //Create Excel WorkBook and WorkSheet
   xlsWorkBookCollection    = xlsApplication.workbooks();
   xlsWorkBook              = xlsWorkBookCollection.add();
   xlsWorkSheetCollection   = xlsWorkBook.worksheets();
   xlsWorkSheet             = xlsWorkSheetCollection.itemFromNum(1);
   //Excel columns captions
   xlsWorkSheet.cells().item(row,1).value("Account Num");
   xlsWorkSheet.cells().item(row,2).value("Name");
         xlsWorkSheet.cells().item(row,3).value("itemId");
  // xlsWorkSheet.cells().item(row,4).value("Name");
   row++;
   //Fill Excel with CustTable AccountNum and Name fields (only 20 records)
   while select custTable where custTable.AccountNum==custAccount

   {
       select inventTable where inventTable.ItemId==ItemId;
      if(row == 20)
        break;
      xlsWorkSheet.cells().item(row,1).value(custTable.AccountNum);
      xlsWorkSheet.cells().item(row,2).value(custTable.Name());
       xlsWorkSheet.cells().item(row,3).value(inventTable.ItemId);

      row++;
   }
   //Check whether the document already exists
   if(WinApi::fileExists(fileName))
      WinApi::deleteFile(fileName);
   //Save Excel document
   xlsWorkbook.saveAs(fileName);
   //Open Excel document
   xlsApplication.visible(true);
   //Close Excel
   //xlsApplication.quit();
   //xlsApplication.finalize();

    }
    else
    {
        error( 'Customer Account not found!');
    }
}

output:

Related
Recommended