Auto populate field on catalog item.

Abhijit Das7
Tera Expert

Hi Everyone,

 

I have one custom field on catalog item - Requester (this is reference field to User table). I have to auto populate this field with current logged in user whenever I open this catalog item.

 

Please suggest some way.

 

Thanks in advance

 

5 REPLIES 5

Robbie
Kilo Patron
Kilo Patron

Hi @Abhijit Das7,

 

This functionality is available for you out of the box. Simply change or make sure your variable 'Type' is 'Requested For'.

It will auto populate with the logged in user.

 

Screenshot 2024-09-23 at 10.46.57.png

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

Community Alums
Not applicable

Hi @Abhijit Das7 ,

Please use the below method in the Requested For field:

gs.getUserID(); -> Auto-populate logged in user.

Please mark it as "Helpful" and "Accepted", if the solution works for you!

Thanks

jkhanddh
Tera Contributor

Hi Abhijit Das7,
For this usecase go to the default value of the variable and use this piece of code - "javascript: gs.getUserID()" and your goal will be achieved

Pratima Kalamka
Kilo Sage

Hello @Abhijit Das7 ,

Please set the Default Value of that requester variable : javascript:gs.getUserID() //name of logged in user

or other you can use the onload catalog client script:

script:

 

function onLoad() {
    var currentUser = g_user.userID;
    if (g_form.isNewRecord()) {
        g_form.setValue('preparer', currentUser);
    }
}

 

 

 

 

 

If my answer is helpful please mark it as helpful or correct!!