Auto Populate A Reference Field

ID NOBLE
Tera Expert

Hi everyone,

 

Please I need a solution to auto populate a variable (Reference type) on a Catalog Item based on the logged in User.

 

 

Thank you.

2 ACCEPTED SOLUTIONS

Clara Lemos
Mega Sage
Mega Sage

Hi @ID NOBLE ,

 

You can add a default value to the variable so that it gets the logged in User information, for example the code below  will auto populate the field with logged in user company.

javascript:gs.getUser().getCompanyID()

 

If that helps please mark my answer as correct / helpful!
And if further help is needed please let me know

Cheers

View solution in original post

Alp Utku
Mega Sage

You can go to the Default Value tab of the reference field and use the below code.

 

javascript: gs.getUserID()

 

 

Additionally, you can create onLoad Catalog Client Script like below

 

 

var loggedusr = g_user.userID;

if (loggedusr != '  ')  {

g_form.setValue('your_field_name', loggedusr) ;

}

 

 

 

View solution in original post

4 REPLIES 4

Clara Lemos
Mega Sage
Mega Sage

Hi @ID NOBLE ,

 

You can add a default value to the variable so that it gets the logged in User information, for example the code below  will auto populate the field with logged in user company.

javascript:gs.getUser().getCompanyID()

 

If that helps please mark my answer as correct / helpful!
And if further help is needed please let me know

Cheers

Thank you for your help. It works.

Alp Utku
Mega Sage

You can go to the Default Value tab of the reference field and use the below code.

 

javascript: gs.getUserID()

 

 

Additionally, you can create onLoad Catalog Client Script like below

 

 

var loggedusr = g_user.userID;

if (loggedusr != '  ')  {

g_form.setValue('your_field_name', loggedusr) ;

}

 

 

 

ID NOBLE
Tera Expert

Thank you for your help. It works.