web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • WillWU Profile Picture
    22,361 on at

    Hi partner,

    Did you set up the form as formRef for HcmWorker?

  • GirishS Profile Picture
    27,827 Moderator on at

    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,

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans