Create new Dictionary attribute

NeilH2
Giga Guru

I am looking to create a new dictionary attribute which would be applied to the assigned to field.
When pressed it would insert the name of the person currently viewing the ticket.

I'm having some trouble however locating where the attribute records are kept.

Any pointers?

1 ACCEPTED SOLUTION

Here's a more elegant solution that just uses a small UI Macro and a dictionary attribute:

http://www.servicenowguru.com/system-ui/ui-macros/add-me-ui-macro-user-group-fields/


View solution in original post

13 REPLIES 13

andrew_venables
ServiceNow Employee
ServiceNow Employee

Shane,



You'll want to use a Decoration for this http://wiki.servicenow.com/?title=Reference_Fields#Decorations



5.3 on the link above has an example that you can modify from incident.



Andy


I am using the "Assign to me" form button as a base to accomplish, but made a new one called "Assign to me (ServiceDesk)".



I tried the following script, but it is not filling in the assignment group field still:



current.assignment_group.setDisplayValue('IT ServiceDesk');


current.assigned_to = gs.getUser();




current.doRedirect = true;


action.setRedirectURL(current);


current.update();




Any ideas?



Thanks


Crusty1
Giga Contributor

ShaneCossever wrote:



I am using the "Assign to me" form button as a base to accomplish, but made a new one called "Assign to me (ServiceDesk)".



I tried the following script, but it is not filling in the assignment group field still:



current.assignment_group.setDisplayValue('IT ServiceDesk');


current.assigned_to = gs.getUser();




current.doRedirect = true;


action.setRedirectURL(current);


current.update();




Any ideas?



Thanks



FYI: Your exact code is working for me, with the exception of the gs.getUser() ... it should be gs,getUserID().



You can accomplish the same thing with:



current.assignment_group.setDisplayValue('Service Desk');


current.assigned_to = gs.getUserID();



current.update();


action.setRedirectURL(current);


That explains a few things.



I tried this, and the page is trying to submit/update, however my Assignment Group flashes and pops up a warning because it is a mandatory field. It is not being filled in still. Will I have to change the script due to the field being mandatory? We don't want anyone submitting an incident without filling in an assignment field.



Thanks!



Edit: I filled in an Assignment Group manually, then tried the form button again, and it filled in the Assigned To field with my username, but emptied out the Assignment Group field and saved the page. Guess I've hit a snag somewhere.



Edit 2: Got things working, but ONLY if assignment group has an entry in it already while I am still on the New incident form. A save is not needed. I go to New incident, fill out something in all of the mandatory fields, and then click my new Form Button, and it fills in the Assignment Group and Assigned To properly. However if Assignment Group has nothing filled in, aka is blank, and I try my new Form Button, it will flash and say it is mandatory. Ccde is:



current.assignment_group.setDisplayValue('IT ServiceDesk');


current.assigned_to = gs.getUserID();



current.update();


action.setRedirectURL(current);