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, ...
Suggested Answer

How to use RefRecId to get the reference value using X++.

(0) ShareShare
ReportReport
Posted on by 185

Hi,

I am working on customization where I have to pick the data from one form to another form on some certain condition using a batch job. The problem is that I have a customized table XYOvertimeRequest in which I have a RefRecId field with the name "HCMWorker" (i.e; XYOvertimeRequest.HCMWorker) and this field is returning the name of an employee using RefGroupField. How I can use this RefRecId field to get the name of an employee in my method ProcessData() of a batch job. Here is my code,

private void ProcessData()

{

    XYOvertimeRequest           overtimeRequest;

    XYOvertimeRequestLines      overtimeRequestLines;

    ABC_BulkPayment            bulkPayment; 

   ttsBegin;

   select * from overtimeRequest

   where overtimeRequest.WorkflowState == TradeWorkflowState::Completed

   && overtimeRequest.ABC_PaymentStatus == ABC_PaymentStatus::NotPicked; 

   if(overtimeRequest.RequestID == overtimeRequestLines.RequestID)

   {

       bulkPayment.OvertimeRequestID = overtimeRequest.RequestID;

       bulkPayment.RequestDate = overtimeRequest.RequestDate;

       bulkPayment.Employee =   (overtimeRequest.HcmWorker); //Here I am finding the operand type error too, also Employee has type string.

       bulkPayment.Department = overtimeRequest.Department;

       bulkPayment.Grade = overtimeRequest.Grade;

       bulkPayment.PlanOvertimeRequestID = overtimeRequest.PlanOvertimeRequestId;

       bulkPayment.TotalHours = overtimeRequest.OTHours();

       bulkPayment.TotalAmount          = overtimeRequest.OTAmounts();

       bulkPayment.insert();

   } 

   ttsCommit; 

}

So is there is any way to get the employee name using this RefRecId, Thanks.

I have the same question (0)
  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi bilal170795,

    RefRecId is a type that usually used for RecId-based relations. It means that field overtimeRequest.HcmWorker contains RecId value for record in HcmWorker table.

    To get name for worker using RecId field, you need to select record from HcmWorker (you can use find record) and use name method to get worker name

    HcmWorker::find(overtimeRequest.HcmWorker).name();

  • Blue Wang Profile Picture
    on at

    hi bilal170795,

    Worker ID:

    HcmWorker::findByPersonnelNumber(workerID).name();

    Worker RecID :

    HcmWorker::find(workerRecid).name();

  • D365 FO Tech Profile Picture
    5 on at

    Thank you so much brother, Love you.

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
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans