OOB Business Rule - Incident Functions - Need Clarification.

J_31
Kilo Sage

Hi 

 

I am practicing client script - to populate caller_id in incident table to logged in user. 

When I tried it didnt work, it getting populated automatically using the OOB business rule "incident functions" - I guess. 

https://XXXservice-now.com/nav_to.do?uri=sys_script.do?sys_id=68c334efc0a80164016c1bce9b634660

 

I was trying to read and understand what the code. there are few methods like gs.action and action.get("sysparm_collection") in the function which is pretty new for me - can someone guide me and help me understand the code. 

 

 

function incidentGetCaller() {
if (gs.hasRole("itil")) {
var action = gs.action;
var table = action.get("sysparm_collection");
if (table != "sys_user")
return null;

var userID = action.get("sysparm_collectionID");
return userID;
}

4 REPLIES 4

Pavankumar_1
Mega Patron

Hi @J_31 ,

Not sure about that business rule but you can use default value on dictionary of caller filed to populate logged in user.

javascript:gs.getUserID()

Screenshot (546).png

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Sagar Pagar
Tera Patron

Hi @J_31,

As Pavan suggested, you can use the default value and it will update the logged in user name as default.

 

Thanks,

Sagar Pagar

The world works with ServiceNow

santhimannem
Tera Contributor

Hi @J_31 ,

You can use default value of caller field to populate logged in user please use below code.

javascript:gs.getUserID()

Pavankumar_1
Mega Patron

Hi @J_31 ,

If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar