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, ...
Answered

Set a default value in reference group control

(0) ShareShare
ReportReport
Posted on by 209

Hi Community experts,

I am want to set a default value in a reference group control.

I want to insert the logged in user's details here in this field

pastedimage1651323193717v1.png

To fetch the data I am using this query (mention in screenshot) and writing this code in OnInitialized DataSource event

pastedimage1651323289753v2.png

As soon as I click the new button the event gets triggered but nothing is getting populated in the field.

Looking forward to helpful responses on this.

Best Regards

I have the same question (0)
  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Ali,

    Do you want to set the logged in user's details in this field, or do you want to set the user creating the record in this field? If you want to set the logged in user's details, every time a user opens this form, the their details will be set on this form. This way you won't be able to check who actually is the requestor of the position action.

    Secondly, rather than setting the form control value, you should set the field value for the table. The field Originator in HcmActionState table has a foreign key relation with HcmWorker table. So, you need to find the HcmWorker record for the currently logged in user. Assuming that you want to set the Originator field when a new action is created, you can create a CoC on initValue method in HcmActionState table. Your code will look like this -

    [ExtensionOf(tableStr(HcmActionState))]
    final class HcmActionState_Extension
    {
    	public void initValue()
        {
            next initValue();
    		this.Originator = HcmWorkerLookup::currentWorker();
        }
    	
    }

  • alinawaz Profile Picture
    209 on at

    Thanks a bunch  Gunjan Bhattachayya 
    The code worked like charm, I was so occupied in making the form control work that I completely forgot about directly assigning value at table level.

    Thanks again Brother, You're a life saver. Cheers

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Glad to be of help Ali :)

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

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans