AnsweredAssumed Answered

ServiceNow - Changing user field format

Question asked by christopher.odediran Advocate on Oct 26, 2017
Latest reply on Nov 6, 2017 by marc.farmen

Wondering if anyone can help here. We are about to move the ServiceNow (Helsinki) integration into production but have one issue. The integration script we were provided writes 'Firstname LastName' to the ServiceNow 'AssignedTo' field. However, we prefer 'Assigned' to to be managed by technicians and not automated.

 

Instead, we have added two fields they can use to reconcile discrepancies between Snow user identification and their manual assignments. We also want to run exception reports based on any discrepancy.

 

The issue is that the two fields are written as 'Domainname\UserID'  and we cannot base any exception reports on this because of the different formats.ServiceNow view

 

So, the help being sought here is how can we modify the script to write  'Firstname LastName' to the other two fields? We have been waiting for too long to get support from Snow. 

 

This is the relevant part of the current script used in ServiceNow , which modifies the AssignedTo field:

 

}

 

function setAssignedTo() {

                var MostName = source.most_frequent_user;

                var LastName = source.last_logged_on_user;

                var usr=new GlideRecord("sys_user");

                var X = 0;

                if (MostName.length > 9){

                                X = MostName.length - 8;

                                MostName= right(MostName,X);

                                if(usr.get("active", MostName)){

                                                if(usr.get("user_name",MostName)){

                                                                target.assigned_to = usr.getUniqueValue();

                                                }

                                } else {

                                                if(LastName.length > 9){

                                                                X = LastName.length - 8;

                                                                LastName = right(LastName,X);

                                                                if(usr.get("user_name",LastName)){

                                                                                target.assigned_to = usr.getUniqueValue();

                                                                }

                                                }

                                }

                } else {

                                if(LastName.length > 9){

                                                X = LastName.length - 8;

                                                LastName = right(LastName,X);

                                                if(usr.get("user_name",LastName)){

                                                                target.assigned_to = usr.getUniqueValue();

                                                }

                                }

                }             

                gs.info("Snow Import: " + source.name + " " + target.assigned_to);

}

Outcomes