Skip to main content

Notifications

Announcements

No record found.

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

  • Hammad Khan Profile Picture
    Hammad Khan 71 on at
    RE: MultiSelect lookup filter query

    Thanks Midhun for reply

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

  • Verified answer
    Hammad Khan Profile Picture
    Hammad Khan 71 on at
    RE: MultiSelect lookup filter query

    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.

  • Midhun Profile Picture
    Midhun 55 on at
    RE: MultiSelect lookup filter query

    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 

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,431 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans