How to populate the current logged in user to caller field if no value present.

k chaitanya kum
Giga Contributor

How to populate the current logged in user to caller field if no value present.

1 ACCEPTED SOLUTION

Hello,

the initialization of the default value for the caller field auto populate the caller field when a new incident is inserted.

I assume that your use case is when an existing incident is existing and for an unknow reason, the caller field is empty ... That shouldn't happen if you set the caller field mandatory ...

To give you the technical answer, please find below the client script code :

function onLoad() {
	
	var userID = g_user.userID;
	
	if (g_form.getValue('caller_id') == '')
		g_form.setValue('caller_id', userID);
	
}

 

View solution in original post

10 REPLIES 10

Hi Chaitanya,

Ok so you can achieve this using onLoad client script.

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Hello,

the initialization of the default value for the caller field auto populate the caller field when a new incident is inserted.

I assume that your use case is when an existing incident is existing and for an unknow reason, the caller field is empty ... That shouldn't happen if you set the caller field mandatory ...

To give you the technical answer, please find below the client script code :

function onLoad() {
	
	var userID = g_user.userID;
	
	if (g_form.getValue('caller_id') == '')
		g_form.setValue('caller_id', userID);
	
}

 

k chaitanya kum
Giga Contributor

Thanks bro its working

Henrik Jutterst
Tera Guru

Even though this is solved, have a look at this solution: How to auto populate with current user

Rohit045
Tera Contributor

Hi Chaitanya,

function onLoad() {
//Type appropriate comment here, and begin script below
var caller = g_user.getFullName();
g_form.setValue('u_caller', caller);

}

Mark Correct if this solves your issue and also hit Like and Helpful.

Thanks

Rohit