How to set current.assigned_to in script without using sys_id

Eric K3
Kilo Guru

I know how to set the assignment_group and assigned_to using sys_id:

current.assigned_to = "f2f86bb36f18c2004523da0cbb3ee467";

How can I set the assigned_to by using users' names, "Jacob McGillicutty", since the sys_id is bad for readability?

1 ACCEPTED SOLUTION

randrews
Tera Guru

i am a little confused here... why are we worried about readability in the script..



using the sys_id ensures that the CORRECT John Smith is assigned to the record instead of just A john smith... the history of the ticket should show the friendly name and be useful for review.. where are you getting the sid that you want it to show the username instead?



if i am doing this in a script.. where i am assigning a bunch of records to one person <not a good idea in a scheduled script if they are going to leave btw> what I would do is define the user as a variable with a value of the sid... so for example...



var John_Smith = 'f2f86bb36f18c2004523da0cbb3ee467' ;



then set the assigned to as john_smith .. or add a comment to the line you have...



current.assigned_to = 'f2f86bb36f18c2004523da0cbb3ee467';   //John Smith



if this is going to be code called moving on and not in a one time script... i would create a system property and put the sid in the system property.. that way if he leaves the company you just change that property and don't have to go find scripts and modify them.



View solution in original post

8 REPLIES 8

BALAJI40
Mega Sage

Hi Eric,



  1) you can call sys id in property and call in the business rule by gs.getProperty('XXXXXXXX');


  2) you can write a script include and call it in required place.


veena_kvkk88
Mega Guru

Hello Eric,



If you know the display value of the field you are setting, you could use this:



current.setDisplayValue('assigned_to', 'Bernard Laboy'); //Bernard Laboy is the Display value here in user table.


devi_putra
Kilo Guru

Hi Eric,




Use this:



current.assigned_to.setDisplayValue('Jacob McGillicutty');



Thanks,


Devi



PS: Hit like, Helpful or Correct depending on the impact of the response.


randrews
Tera Guru

i am a little confused here... why are we worried about readability in the script..



using the sys_id ensures that the CORRECT John Smith is assigned to the record instead of just A john smith... the history of the ticket should show the friendly name and be useful for review.. where are you getting the sid that you want it to show the username instead?



if i am doing this in a script.. where i am assigning a bunch of records to one person <not a good idea in a scheduled script if they are going to leave btw> what I would do is define the user as a variable with a value of the sid... so for example...



var John_Smith = 'f2f86bb36f18c2004523da0cbb3ee467' ;



then set the assigned to as john_smith .. or add a comment to the line you have...



current.assigned_to = 'f2f86bb36f18c2004523da0cbb3ee467';   //John Smith



if this is going to be code called moving on and not in a one time script... i would create a system property and put the sid in the system property.. that way if he leaves the company you just change that property and don't have to go find scripts and modify them.