Use Javascript to dynamically set Assigned To field same as Opened By field.

Todd H_
Kilo Explorer

Hi All, I can't seem to find exactly what I'm looking for, or am not thinking about putting the correct things together to get this working. 

 

When a few team members and I want to send an incident back to the originating technician, we typically use templates for the work note and state. However, we manually copy the technician's name from the Opened By field into the Assigned to Field. 

 

It would be beneficial and save some time when re-assigning incidents. 

 

I know we can use something similar to below to get the CURRENT user's ID:

javascript:gs.getUserID()

 

I tried to string some things together to figure out the best way to assign to the opening tech by creating a template with the criteria of Assigned to   is   : 

javascript: 
var opener = [];
var inc = new GlideRecord('incident'); 
inc.get('opener','Opened By');
opener.push(inc.getValue('Opened By'));

Sadly, the above only shows that I attempted to modify the Assigned to field, but nothing actually shows up. 

 

What would your suggestions for this be? 

 

 

 

 

7 REPLIES 7

looks like you need server side code. Find solution here

https://community.servicenow.com/community?id=community_question&sys_id=b18dc32ddb9cdbc01dcaf3231f961984

Abhinay Erra
Giga Sage

Try this

javascript: gs.getUser().getUserByID(current.getValue('opened_by')).getID();

weikiat_guaz
Giga Expert

I think you need to add "current". 

try javascript:current.getValue('opened_by');