web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

MultiSelect lookup filter query

(0) ShareShare
ReportReport
Posted on by 71

i want to filter mutilselct lookup based on Employment type 
For an instance we have labors and staff

on init method i have written this code

Query query = new Query(queryStr(HcmWorkerListPage_Employees));
QueryBuildDataSource qbds;
super();
query.clearAllFields();
qbds=query.dataSourceTable(tableNum(HcmWorker));
qbds.fields().addField(fieldNum(HcmWorker,PersonnelNumber));
qbds.fields().addField(fieldNum(HcmWorker,Person));
msCtrlCust = SysLookupMultiSelectCtrl::constructWithQuery(element, MultiLookup, query);

its working fine 
now on modified method of combox

boolean ret;

ret = super();
if (str2int( this.valueStr())==EmployeeTypeLeave::Staff)
{
element.changeWorkerLookup("HcmWorkerListPage_Employees");
}
else if (str2int( this.valueStr())==EmployeeTypeLeave::Labor)
{
element.changeWorkerLookup("HcmWorkerListPage_Labors");
}

return ret;

now 
what code do i need to write on changeWorkerLookup  method since i already construct lookup?
can i reinitialize the whole control? (that also can work for me)
i cannot use refreshQueryRun coz getting error wrong argument type for function.





*This post is locked for comments

  • Midhun Profile Picture
    55 on at

    Hi Hammad,

    Even I'm also looking for that solution. Some how I'm able to achieve partially. 

    What I've done is, while constructing the dynamic query, I'm applying the range. In your case based on the Employment type. So that it will filter based on the range. but the problem is am not able to filter it again. My scenario was Based on the First lookup i need to filter the second lookup(Which is a multi select lookup) and that too in a Dialog class. 

    hope this information will help at least.

    Regards,

    Midhun 

  • Verified answer
    Hammad Khan Profile Picture
    71 on at

    ok so i figured it out.

    you simply cannot use query with relation on queryRun object. i duplicated HCMworker table remove relation and pass the query to queryRun object. and it works fine. but problem is now Recid instead of person name in lookup.

    to fix this i made a new temp table(InMemory) with Field Name(from DirPerson) and personnelNumber(HcmWorker) and NO RELATIONS on it.

    on init i filled the table with select query i.e inner join Dirperson and HCmWorker and sets the cursor to my form datasource Temptable

    to refresh i refills table with staff only employee for example set the cursor and called refreshquery

    Hope it help for someone looking for same question.

  • Hammad Khan Profile Picture
    71 on at

    Thanks Midhun for reply

    i figured it out check my answer if you are still looking for answer.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans