Custom lookup fields to allow the user to select multiple values

Earlier stage u said me u set ur Look_up property ReplaceOnLookup – > “No” u must change into ReplaceOnLookup – > “Yes” then try it I am sure it will execute perfectly

See my Output here Look_up.jpg

Even with setting it back to Yes, I still get the same error. The error doesn’t make sense to me because the field is in the table. The error is the Table does not contain this field.

I tried adding similar logic onto a standard AX field and I got the same error code. Can you post your code?

public void lookup()
{
 Query query = new Query();

QueryBuildDataSource queryBuildDataSource, qbds, dsView;

QueryBuildRange queryBuildRange;


SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(SO), this);
;
sysTableLookup.addLookupField(fieldNum(SO, Selection_Origin));
sysTableLookup.addLookupField(fieldNum(SO, Name));
sysTableLookup.addLookupField(fieldNum(SO, Blanket_PO_Number));

queryBuildDataSource = query.addDataSource(TableNum(SO));       // So Data Source Start (2nd Table)


qbds = queryBuildDataSource.addDataSource(TableNum(PO));       //PO Data Source Over



qbds.joinMode(JoinMode::InnerJoin);

qbds.addLink(FieldNum(SO,RefId),FieldNum(PO,ID));

sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

See u may did some silly error try to do in new form with single lookUp

I’ve tried re-writing my lookup similar to what you have and I get an error. “The data source is not embedded within a (parent) data source.” The below code is the only way I can get the values.

The value of the field is custVendExternalItem.idcItemValueService, which is a custom field I added to the table.

public void lookup()
{
Query query = new Query();
QueryBuildDataSource qbdsValueAdd;
sysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(IDC_ItemValueAddedService), this);
;

sysTableLookup.addLookupField(fieldNum(IDC_ItemValueAddedService, ItemVASCode));
sysTableLookup.addLookupField(fieldNum(IDC_ItemValueAddedService, Description));

qbdsValueAdd = query.addDataSource(tableNum(CustVendExternalItem));
qbdsValueAdd.joinMode(JoinMode::InnerJoin);
qbdsValueAdd.addLink(fieldNum(IDC_ItemValueAddedService, ItemVASCode), fieldNum(CustVendExternalItem, idcItemValueAddedService));

sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

I am sure You’re calling addLink() on the wrong datasource. check it

You’ll be able to find such bugs more quickly if you become using more descriptive names for your variables.

(or)

try this one

qbdsValueAdd = query.dataSourceTable(tableNum(CustVendExternalItem)).addDataSource(…);

I name my variables to what they stand for. qbdsValueAdd - ValueAdd is the customization that I am putting in place for our company. The addlink and the last option you provided do not work. AX locks up on me with the code in there.