Auto papulate caller details in caller filed /Incident table

khasim523169
Tera Contributor

Hi Team

pls advice , how to auto populate caller id details  in caller filed, while loading the incident form..

 

i am using, client script but it is not working 

 

find the attached images

Regards

khasim

2 ACCEPTED SOLUTIONS

Prathamesh G
Kilo Sage
Kilo Sage

Hello @khasim523169 ,

 

You can the below code in you onLoad client script:

 

function onLoad() {
	g_form.setValue('caller_id', g_user.userID);
}

 

If the above solution resolve your issue, Please mark the solution as 'Accepted Solution' and also mark it as 'Helpful'.

 

Thank You!

Prathamesh.

View solution in original post

Community Alums
Not applicable

Hello @khasim523169 ,

 

Use the onload Client Script:

function onLoad() {
// Check if the record is new - Don't modify existing record
   if(g_form.isNewRecord()){
    g_form.setValue('caller_id', g_user.userID);
   }
}

 

If this solves your query mark this as correct and helpful.

 

Thanks

Anand

View solution in original post

4 REPLIES 4

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @khasim523169 

 

Try this:

 

function onLoad() {
// Get the current user's sys_id and name
var userId = g_user.userID;
var userName = g_user.userName;

// Set the value of the caller field on the Incident form
g_form.setValue('caller_id', userId, userName);
}

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Brad Bowman
Kilo Patron
Kilo Patron

Your script would almost work if there was a field named g_user on the form that was populated.  If you are attempting to retrieve the current user and populate it in the Caller field, try this:

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

 or simply

function onLoad() {
	g_form.setValue('caller_id', g_user.userID);
}

Prathamesh G
Kilo Sage
Kilo Sage

Hello @khasim523169 ,

 

You can the below code in you onLoad client script:

 

function onLoad() {
	g_form.setValue('caller_id', g_user.userID);
}

 

If the above solution resolve your issue, Please mark the solution as 'Accepted Solution' and also mark it as 'Helpful'.

 

Thank You!

Prathamesh.

Community Alums
Not applicable

Hello @khasim523169 ,

 

Use the onload Client Script:

function onLoad() {
// Check if the record is new - Don't modify existing record
   if(g_form.isNewRecord()){
    g_form.setValue('caller_id', g_user.userID);
   }
}

 

If this solves your query mark this as correct and helpful.

 

Thanks

Anand