OnLoad Clentscript

bhavanakuruba
Giga Contributor

Hello team,

Good day, 

 

I have a query regarding OnLoad client script,

Can you please share the script for below query

 

Auto populate the logged user in Reported by field

 

Thank you

 

2 REPLIES 2

GlideFather
Tera Patron

Hi @bhavanakuruba 

 

you'd need to provide more details, this is way too abstract..

 

Firstly, client script is associated with a table where is that field - incident, demand, location, ..... so please create an onLoad client script applied on this table and the script could be something like this:

g_form.setValue('reported_by', g_user.getUserID()); //check the field name

 

EDIT:  correction above: g_user.userID >>> g_user.getUserID()

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


@bhavanakuruba 

correction > it's g_user.getUserID();

 

see my test:

GlideFather_0-1754998181610.png

 

 

Also, there should be verification that the field is empty, because if I will create a new record (incident in my example) it will pre-populate the Caller by the logged in user, then I will save it the value will remain but if somebody else will continue working on it, it will next time populate with that person...

 

So perhaps the onLoad client script isn't the best idea... instead you could set the default value. What do you think about it?

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */