Multi select lookup in UI Builder class in D365F&O through x++ code.

 Hi Viewers,

Below is the code sample for Multi-select lookup in the SSRS report by UI builder class.

In this example, I am using

  •  UI builder class - ItemListUIBuilder
  • Contact class - ItemListContract
  • DP class - ItemListDP

In the contract class add a list-type parameter, as shown below. Contract class must decorated with attributes as shown below. give the ULBuilder class name to SysOperationContractProcessingAttribute

[ DataContractAttribute,     SysOperationContractProcessingAttribute(classStr(ItemListUIBuilder))]

class ItemListContract

{

  List                        ItemIDList;

  [   DataMemberAttribute,
        AifCollectionTypeAttribute("Item Id", Types::String)      ]

    public List parmItemIdList(List _ItemIDList = ItemIDList)
    {
      ItemIDList = _ItemIDList;
      return ItemIDList;
    }
}

Now create UI Builder class as shown below code:

class ItemListUIBuilder extends SysOperationAutomaticUIBuilder
{
    ItemListContract contract;

      public void build()
    {        
        
        contract                            = this.dataContractObject();

        dlgGroupOrderLines                  = dialog.addGroup("@SYS508");

        dialogItemList                      = this.addDialogField(methodStr(PPCSalesLineContractCopy,                                                                                 parmItemIdList), contract);
    }

     public void postRun()
    {
      this.ItemIdLookup();
        super();
    }

    public void ItemIdLookup()
  {
  
    Query query = new Query(queryStr(InventTable));
    QueryBuildDataSource qbds;
    container conItemId = [ tableNum(InventTable), fieldNum(InventTable, ItemId) ];
    SysLookupMultiSelectCtrl multicltr;
  
    multiSelectControlMap = new Map(Types::Class, Types::Class);

    multicltr = SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(),        dialogItemList.control(), query, false, conItemId);
    multiSelectControlMap.insert(dialogItemList, multicltr);
   dialogItemList.control(),dialogItemList.control(), conItemId);
  }

}

In the DP class use this sample logic to get values and process 

        contract                    = this.parmDataContract() as ItemListContract;
        itemId                      = contract.parmItemId();

        ItemIdListIterator = new ListIterator(itemId);

          while(ItemIdListIterator.more())
          {
            qbds.addRange(fieldnum(SalesLine, itemId)).value(ItemIdListIterator.value());
            ItemIdListIterator.next();
          }

Comments

Popular posts from this blog

Cannot select a record for update when the transaction is not started on the user connection attached. You need to begin transaction on the user connection first. in d365F&O

Records to include in SSRS Report With UI Builder class