1

i wrote a query as follows and i want to block multiple selection for accountnum in query. Is there any way for to do this in code ?

Query = new Query();
qbdsVendTransOpen = Query.addDataSource(tableNum(VendTransOpen));
qbdsVendTrans = qbdsVendTransOpen.addDataSource(tableNum(VendTrans));
qbdsVendTrans.relations(true);
qbdsVendTrans.joinMode(JoinMode::InnerJoin);

qbdsVendTable = qbdsVendTrans.addDataSource(tableNum(VendTable));
qbdsVendTable.relations(true);
qbdsVendTable.joinMode(JoinMode::InnerJoin);

qbdsVendTable.addRange(fieldNum(VendTable,accountNum));
Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71
Mumble
  • 141
  • 1
  • 8
  • 2
    There's a design concept in AX that you're missing here. You're exposing the query directly to the user. Your query should be wrapped in an abstracted UI. – Alex Kwitny May 11 '20 at 03:25

2 Answers2

5

I don't think this can be done easily within the query dialog. I would suggest locking the range (see @Jonathan Bravetti's answer) and building a custom dialog or field before calling the query dialog. The user would enter the account number in the custom ui and then you can use code to transfer the entered value to the query.

FH-Inway
  • 4,432
  • 1
  • 20
  • 37
3

If you want lock your range add this line:

qbdsVendTable.addRange(fieldNum(VendTable,accountNum)).status(rangestatus::Locked);
Jonathan Bravetti
  • 2,228
  • 2
  • 15
  • 29
  • Thanks for your answer @Jonathan but if i do that, user can not select any accountnum value. I want that user can only select one value, when user selects second value delete previous value – Mumble May 10 '20 at 05:46
  • 1
    Ok, now is clear the question. So I concur with answer @FH-Inway follow their advice. – Jonathan Bravetti May 11 '20 at 11:57