Hi all ,How to use Get reference in onload service catalog client script ..Please help

Rishi13
Giga Contributor

g_form.getReference();

1 ACCEPTED SOLUTION

Community Alums
Not applicable

From the name of your script, I'm guessing you want to populate a field with the currently logged in user.  

For that, you could use the following line of code to set the field 'requested_for' with the current user.

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

 

You should check out this developer documentation on the GlideForm API and search for the following to see more information on how to set a value:

setValue(String fieldName, String value)

 

View solution in original post

6 REPLIES 6

Hitoshi Ozawa
Giga Sage
Giga Sage

What is the use case to call getReference()?

Display business rule is often used to retrieve data to display on a form. What will getReference() planned to be used?

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

can you explain your business requirement here with example and screenshot?

what exactly you want to achieve?

Regards
ankur

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

Hi,

 

I am beginner to service now..

I am working  OnLoad Service Catalog .were I should use ,get reference(instead of Glide record ) to call table sys_user.

 

pls find attachment.

 

 

Thank you.

Community Alums
Not applicable

From the name of your script, I'm guessing you want to populate a field with the currently logged in user.  

For that, you could use the following line of code to set the field 'requested_for' with the current user.

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

 

You should check out this developer documentation on the GlideForm API and search for the following to see more information on how to set a value:

setValue(String fieldName, String value)