How to make the lookup with unselected record

I’ve already selected the quarantine id(QN00000070) for the item number 6143.2000…

So Wen I try to lookup the quarantine id again this id need not to show again in the form.

How can i do that?

You would have to add a range (or more ranges, if you have several lines) to the query used for the lookup. If it currently uses a lookup automatically generated by AX, you’ll have to implement a custom one by overriding lookup() method.

public void lookup()
{

    SysTableLookup        sysTableLookup;
    Query                 query=new Query();
    QueryBuildDataSource  qbds,qbds1;

    ;
    sysTableLookup=SysTableLookup::newParameters(tablenum(InventQuarantineOrder),this);

    sysTableLookup.addLookupfield(fieldnum(InventQuarantineOrder,QuarantineId));
    sysTableLookup.addLookupfield(fieldnum(InventQuarantineOrder,ItemId));
     sysTableLookup.addLookupfield(fieldnum(InventQuarantineOrder,Name));
    sysTableLookup.addLookupfield(fieldnum(InventQuarantineOrder,Qty));
    sysTableLookup.addLookupfield(fieldnum(InventQuarantineOrder,Status));
    sysTableLookup.addLookupfield(fieldnum(InventQuarantineOrder,QuarantineDate));
   sysTableLookup.addLookupfield(fieldnum(InventQuarantineOrder,InspectionStatus));
    qbds = query.addDataSource(tablenum(InventQuarantineOrder));
   // qbds1 = query.addDataSource(tablenum(InventDim));
    qbds.addRange(fieldnum(InventQuarantineOrder, ItemId)).value(Overview_ItemId.valueStr());
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

I’ve added this lookup method in this stringedit control, Martin.

how should i filter it?

Based on the item id I’m showing lookup for the Quarantineid in the form, once the quarantine id got selected for the item number, when I add the item again in form the remaining q id’s need to show in the lookup…

Add a range for QuarantineId field and set the value to SysQuery::valueNot(“QN00000070”).

How can i specify the range without giving SysQuery::valueNot(“QN00000070”) ??

Sorry, I don’t understand your question. Please elaborate it.

If i gave value like this SysQuery::valueNot(“QN00000070”) that particular id only will not get added in that lookup…

See if i have multiple quarantine id’s for particular item and If i added one qid for this item number and when I create a record with this item number already selected qid should not appear in that lookup…

How should I do like that?

I’m sorry, but I still didn’t get what problem you have with the solution.
An alternative to using ranges (better if you have several lines) is a notexists join.

Instead of manually giving that Qid there SysQuery::valueNot(“QN00000070”)… Is it possible to give manually ??

I mean for that particular item number if that quarantine id exists that should not show in the lookup,like that…

Do you mean whether you can replace “QN00000070” with another value at runtime? Of course, it was just an example, I thought it was obvious. Use a variable instead of the hard-coded string “QN00000070”.

Like this a=inventquarantineorder.quaratineid;
and use this variable a in SysQuery::valueNot(“a”);
Am I right?

My apologies, I thought you already knew basics of X++ programming, such as how to use variables.

Text in quotes (single or double), such as “a”, is a co-called “string literal”. It’s simply a static text, in this case a.

Variables are basically named values and you refer to them without double quotes. You may want to create a new one, but you also can use existing variables, such as inventQuarantineOrder.QuaratineId in your example. Therefore you could call SysQuery::valueNot(inventQuarantineOrder.QuaratineId), if inventQuarantineOrder contained the record you want (which it probably doesn’t). By the the way, please don’t ignore casing in variable names, inventQuarantineOrder is much easier to read than inventquarantineorder.

If you want to create a new variable, you start with a declaration of its type and name, such as str a;. Then you assign a value, as you did above; you can also do declaration and assignment at this same time, like this:

str a = "This is the new value of variable a";

i thought u will understand that I declared that a as str before tats way I’ve not added declaring that str a; line above…

I did. But I saw you didn’t realize the difference between a and “a”.

I know the difference b/w str and an static text, Martin… Its my mistake nly I might mention it before while replying for the post