Recently, I had a requirement to show multiple selected records from Item master form to a new form, when a button is clicked on the Item master form. I wrote all the necessary code using MultiSelectionHelper class in X++ and applied the range on form’s datasource, but it was showing only one selected record on the new form instead of all the selected records. After wasting lot of time on this, I was finally able to figured out the solution which I want to share. The problem was that due to the dynalink created between the InventTable and the datasource on my new form, it was preventing all the selected records to be shown and only one record was showing on my new form. So, the solution is to clear the dynalinks on the datasource before applying the ranges. Below is the code I wrote in the datasource’s init method on my new form which is called from Item master form:

public void init()
MultiSelectionHelper multiSelectionHelper;
InventTable inventTableLocal;

QueryBuildDataSource qbds;

str selectedProducts;


if (element.args().caller() &&
multiSelectionHelper = MultiSelectionHelper::construct();

inventTableLocal = multiSelectionHelper.getFirst();

while (inventTableLocal.RecId != 0 &&
EcoResProduct::find(inventTableLocal.Product).productSubtype() == EcoResProductSubtype::ProductMaster)
selectedProducts = queryRangeConcat(selectedProducts, inventTableLocal.ItemId);

inventTableLocal = multiSelectionHelper.getNext();


addRange(fieldNum(EcoResProductMaster, DisplayProductNumber)).value(selectedProducts);