web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Auto populate the fields values

(1) ShareShare
ReportReport
Posted on by 36
Hi All,
 
I have created a form having fields Person(lookup field-through relation with hcmworker),location,jobposition and Name...When i select a person from lookup then the other 3 fields will show the information related to that selected person.
 
Kindly suggest me a solution for this ...how we will achieve this..
Thanks in advance
 
 
Thanks,
Prasad N.
I have the same question (0)
  • Kevin Xia Profile Picture
    Microsoft Employee on at
    Auto populate the fields values
    Hi,
    You can do this by customizing the development of a person field that listens for clicks on the person field and updates the other fields when a person is selected.
    Best regards,
    Kevin
  • PN-21051232-0 Profile Picture
    36 on at
    Auto populate the fields values
    Hi Kevin,
     
    Thanks for the reply...
     
    can you please tell me on which method and where(form/table) we need to do the field customization ...please send/post the code,if you dont mind...i tried with modified field method in form as well as table, but it is not working.
     
     
    Thanks,
    Prasad N.
  • André Arnaud de Calavon Profile Picture
    300,721 Super User 2025 Season 2 on at
    Auto populate the fields values
    HI Prasad,
     
    You can take two approaches here. You can have physical fields for the other 3 fields or use display methods. In case of physical fields, you can add logic to the table method modifiedField() and fill them. With virtual fields, the data will be always show current values and prevent data redundancy or the need to update values in case the master data changes. 
  • PN-21051232-0 Profile Picture
    36 on at
    Auto populate the fields values
    Hi Andre,
     
    Thanks for the reply...
     
    Here, the other 3 fields are display fields in HcmWorker table ..i tried to call these methods in table level but data not populating in the respected fields..
     
    can you please explain more elaborate....please
     
     
    Thanks ,
    prasad N. 
  • André Arnaud de Calavon Profile Picture
    300,721 Super User 2025 Season 2 on at
    Auto populate the fields values
    Hi Prasad,
     
    Can you share the coding you used in your current attempt?
  • PN-21051232-0 Profile Picture
    36 on at
    Auto populate the fields values
    Hi Andre,
     
    i tried the code similar like below ....
    Please check...please reply with corrected code (if any)
     
    public void modifiedField(FieldId _fieldId)
    {
        HcmWorker                   workerTable;
        HcmPosition                 hcmPosition;
        super(_fieldId);
        if (_fieldId == fieldNum(EH_ITAppAccess, Person))
        {
            if (this.Person)
            {
                // Retrieve HcmWorker record once
                workerTable = HcmWorker::findByPersonnelNumber(this.Person);
                // Check if HcmWorker record exists
                if (workerTable)
                {
                    this.WorkerName = workerTable.searchName();
                    // Retrieve office location only if HcmWorker record exists
                    this.Location = workerTable.officeLocation();
                }
                // Retrieve HcmPosition record once
                hcmPosition = HcmPosition::findByPosition(this.Person);
                // Check if HcmPosition record exists
                if (hcmPosition)
                {
                    // Retrieve job position only if HcmPosition record exists
                    this.JobPosition = hcmPosition.description();
                }
            }
        }
    }

     
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    300,721 Super User 2025 Season 2 on at
    Auto populate the fields values
    Hi Prasad,
     
    You have some issues in your coding, I think. What value is stored in the Person field? If it is the DirParty reference, you won't find any record if you use the mehtod HCMWorker::findByPersonnelNumber. This method expects a Personnel number. Probably you need to use HCMWorker::findByPerson instead.
    The same is also an issue with finding a position. The method you used expects a position value, not a person. There is a method on the HCMWorker table to find the primary position of the worker.
     
     
  • PN-21051232-0 Profile Picture
    36 on at
    Auto populate the fields values
    Hi Andre,
     
    Below is the code i used in my table level...can you please check and do the corrections if any...please
     
     public void modifiedField(FieldId _fieldId)
        {
            super(_fieldId);
            HcmWorker                   workerTable;
            HcmPosition                 hcmPosition;
           
            if (_fieldId == fieldNum(EH_ITAppAccess, Person))
            {
                if (this.Person)
                {
                    // Retrieve HcmWorker record once
                    workerTable = HCMWorker::findByPerson(this.RecId);
                    // Check if HcmWorker record exists
                    if (workerTable)
                    {
                        this.WorkerName = workerTable.searchName();
                        // Retrieve office location only if HcmWorker record exists
                        this.Location = workerTable.officeLocation();
                    }
                    // Retrieve HcmPosition record once
                    hcmPosition = HcmPosition::findByPosition(this.Person);
                    // Check if HcmPosition record exists
                    if (hcmPosition)
                    {
                        // Retrieve job position only if HcmPosition record exists
                        this.JobPosition = workerTable.primaryPositionId();
                    }
                }
            }
        }
  • André Arnaud de Calavon Profile Picture
    300,721 Super User 2025 Season 2 on at
    Auto populate the fields values
    Hi Prasad,
     
    Have you already tried your new coding and what is the outcome? I don't know the details of your EH_ITAppAccess table, but it doesn't make sense to use the record ID of this table to find the worker. You would need to use this.Person instead of this.RecId.
     
    If you are using workerTable.primaryPositionId(), you don't need to find the HCMPosition anymore. You are still trying to find a record with the wrong field. Then the if statement will return false and the primary position ID will no be filled.
  • PN-21051232-0 Profile Picture
    36 on at
    Auto populate the fields values
    Hi Andre,
     
    out of 3 fields 2 fields getting data when i select a person from lookup...but location is not getting data...why because this will get from DimFinancialTag table Value field data to reflect in the location field...can you please guide me how we will get this through the indirect relation between HcmWorker and Dimfinancialtag..
     
    Thanks,
    Prasad.

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 683 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 398 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans