Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Lookup for Reference group control

(0) ShareShare
ReportReport
Posted on by 10

public class CerficateRequestWorkerLookup
{

/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(CertificateRequest, CertificateRequest_Worker), FormControlEventType::Lookup)]
public static void CertificateRequest_Worker_OnLookup(FormControl sender, FormControlEventArgs e)
{
HcmWorker hcmworker;
HcmPositionRecId hcmpositionRecId;
HcmPositionHierarchy hcmPositionHierarchy;
HcmPosition hcmposition;
HcmPositionWorkerAssignment workerAssignment;
HcmWorkerRecId hcmWorkerRecid;
UserId userId = curUserId();
int64 recid;
WorkerTable WorkerTable;
DirPersonUser dirPersonUser;
DirPerson dirPerson;
DirPartyTable dirPartyTable;

ttsbegin;
delete_from WorkerTable;
ttscommit;


hcmpositionRecId = HcmPosition::find(HcmPositionWorkerAssignment::getActivePositionWorkerAssignment(HcmWorker::find(HcmWorker::userId2Worker(userid)).RecId).Position).RecId;


while select hcmPositionHierarchy
where hcmPositionHierarchy.ParentPosition == hcmpositionRecId
join hcmposition where hcmposition.RecId == hcmPositionHierarchy.Position
join workerAssignment where workerAssignment.Position == hcmposition.RecId
join hcmworker where hcmworker.RecId == workerAssignment.Worker
{
WorkerTable.Worker = hcmworker.Person;

WorkerTable.insert();
}
select * from hcmWorker
where hcmWorker.RecId == hcmWorker::userId2Worker(curUserId());

select * from dirPerson
where dirPerson.RecId == hcmWorker.Person;

select * from dirPartyTable
where dirPartyTable.RecId == dirPerson.RecId;
WorkerTable.Worker = hcmworker.Person;


WorkerTable.insert();

SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tableNum(WorkerTable),sender);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;

sysTableLookup.addLookupField(fieldNum(WorkerTable,Worker));
sysTableLookup.addLookupField(fieldNum(WorkerTable,PersonnelNumber));
queryBuildDataSource = query.addDataSource(tableNum(WorkerTable));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
ce.CancelSuperCall();
}

}

Hi All,

I got issue when i create lookup on reference group control.i took event handler lookup.here Worker is Recid.Based on condition we insert the data into WorkerTable.In that Worker Table we need lookup in certificate request form.Finally i got the issue as shown below screen.pastedimage1652274481991v2.png

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Lookup for Reference group control

    Hi mohammed,

    Try to join "HcmWorker" table to the lookup query. This will solve the issue. Also add the lookup field from HcmWorker table instead of "WorkerTable".

    Thanks,

  • WillWU Profile Picture
    22,352 on at
    RE: Lookup for Reference group control

    Hi partner,

    Did you set up the form as formRef for HcmWorker?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,011 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans