Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

lookup on all jobs and department in position x++

Posted on by 339
I need to create lookup on field get all jobs , descriptions and department in positions group by jobs (I need job appear one time avoid duplicate)
I tried this but field of department is empty 
            Query                   query;                QueryBuildDataSource    QueryBuildDataSource,QueryBuildDataSource1 , QueryBuildDataSource2;                SysMultiTableLookup SysMultiTableLookup;                query = new Query();                  QueryBuildDataSource = query.addDataSource(tableNum(HcmJob));                QueryBuildDataSource.addGroupByField(fieldNum(HcmJob,JobId));                //join the translation table so we can get a description of the UOM                QueryBuildDataSource1 = QueryBuildDataSource.addDataSource(tableNum(HcmJobDetail));                QueryBuildDataSource1.joinMode(JoinMode::InnerJoin);                QueryBuildDataSource1.relations(true);                QueryBuildDataSource1.addLink(fieldNum(HcmJob,RecId),fieldNum(HcmJobDetail,Job));                QueryBuildDataSource1.addGroupByField(fieldNum(HcmJobDetail,Description));                QueryBuildDataSource2 = QueryBuildDataSource1.addDataSource(tableNum(HcmPositionDetail));                QueryBuildDataSource2.joinMode(JoinMode::InnerJoin);                QueryBuildDataSource2.relations(true);                QueryBuildDataSource2.addLink(fieldNum(HcmJobDetail,Job),fieldNum(HcmPositionDetail,Job));                QueryBuildDataSource2.addGroupByField(fieldNum(HcmPositionDetail,Department));                QueryBuildDataSource2.addRange(fieldNum(HcmPositionDetail,Department)).value(queryValue(CFMJobRequisition.Dept));                QueryBuildDataSource2.addRange(fieldNum(HcmPositionDetail,Department)).status(RangeStatus::Locked);                //define multiple table lookup query                SysMultiTableLookup  = SysMultiTableLookup::newParameters(_formControl, query);                QueryBuildDataSource.addRange(fieldNum(HcmJob,JobStatus)).value(queryValue('Active'));                QueryBuildDataSource.addRange(fieldNum(HcmJob,JobStatus)).status(RangeStatus::Locked);                SysMultiTableLookup.addLookupfield(fieldNum(HcmJobDetail,Job), true);                SysMultiTableLookup.addLookupfield(fieldNum(HcmJobDetail,Description),2);                SysMultiTableLookup.addLookupfield(fieldNum(HcmPositionDetail,Department),3,true);                SysMultiTableLookup.performFormLookup();
 
 
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 5,955 Super User 2024 Season 2 on at
    lookup on all jobs and department in position x++
     
    Can you give me more details about your requirement? you need to return jobs as a lookup based on position? Give me example about the data how it should be returned, because the structure as the following:
     
    1- HcmPosition(Position) has a relation with HcmPositionDetail
    2-HcmPositionDetail has a relation with Department 
    3-HcmPositionDetail has a relation with HcmJob
    4- HcmJob has a reation with HcmJobDetails(that contain Job Description field)
     
     
    Regards,
    Waed Ayyad
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
     
  • Suggested answer
    GirishS Profile Picture
    GirishS 27,832 Super User 2024 Season 1 on at
    lookup on all jobs and department in position x++
    Hi Menna,
     
    I would suggest you create a custom view with all the required tables and add group by of fields inside the view itself.
    You can use that view in the lookup as DataSource for the query.
     
    Thanks,
    Girish S.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,900 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,275 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans