We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

how to automaticlly populate an opened by with the logged in user

Uthman
Tera Contributor

How to automatically populate an opened by with the logged-in user

3 ACCEPTED SOLUTIONS

anandmahaja
Kilo Sage

Hi @Uthman ,

 

Where do you want to auto populate Native view or catalog item?

You can set default value to:

javascript: gs.getUserID();

 

Thanks

Anand

View solution in original post

garimakharb
Tera Guru

 

Set the Default Value to javascript:gs.getUserID()

.gs.getUserID() gets the Sys ID of the currently logged-in user

 

View solution in original post

Ankur Bawiskar
Tera Patron

@Uthman 

Below approaches

1) Recommended - Default value in dictionary

javascript: gs.getUserID();

OR

2) If field is on form then you can use onLoad client script

g_form.setValue('opened_by', g_user.userID);

OR

3) Display business rule on your table

current.opened_by = gs.getUserID();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Dr Atul G- LNG
Tera Patron

Hi @Uthman 

 

https://www.servicenow.com/community/developer-forum/auto-populate-the-user-field-with-logged-in-use...

https://www.youtube.com/watch?v=8jvrvdx5F2Y

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

anandmahaja
Kilo Sage

Hi @Uthman ,

 

Where do you want to auto populate Native view or catalog item?

You can set default value to:

javascript: gs.getUserID();

 

Thanks

Anand

garimakharb
Tera Guru

 

Set the Default Value to javascript:gs.getUserID()

.gs.getUserID() gets the Sys ID of the currently logged-in user

 

Ankur Bawiskar
Tera Patron

@Uthman 

Below approaches

1) Recommended - Default value in dictionary

javascript: gs.getUserID();

OR

2) If field is on form then you can use onLoad client script

g_form.setValue('opened_by', g_user.userID);

OR

3) Display business rule on your table

current.opened_by = gs.getUserID();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader