- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2013 01:57 AM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2013 04:21 AM
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/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2013 06:56 AM
Not sure if I completely understand the requirement, but it sounds like you want to assign a ticket to the person who is currently viewing it. If this is correct, my other guess is that you only want this assignment to occur if there is no one already assigned to the ticket. If all this is true, you may be better off with a client script that fires onLoad and if the assigned_to = "" it will be set to gs.getUserID() . I hope this helps, but sorry if I misunderstood the requirement!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2013 07:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2013 09:02 AM
Client Script on the Task table:
Type: OnLoad
function onLoad() {
//var el = document.getElementById("incident.assigned_to");
if (g_user.hasRole("itil")) {
//Add a UI macro to a non-reference field
//Set the name of the field in the 'field' variable
var field = "assigned_to";
//Append the table name to get the field id
field = g_form.tableName + "." + field;
try {
//Create the image element and add to the dom
var img = document.createElement('img');
img.src = "yperson.pngx";
img.alt="Assign Incident to Me";
img.title="Assign Incident to Me";
var link = document.createElement('a');
if (navigator.appName == "Microsoft Internet Explorer") {
link.setAttribute('onclick', Function('toMeClick()'));
}
else {
link.setAttribute('onclick', 'toMeClick()');
}
link.name="assign_to_me";
link.id="assign_to_me";
link.appendChild(img);
link.style.display = 'inline';
document.getElementById(field).parentNode.appendChild(link);
}
catch(e) { }
}
}
//onclick event to fire when the image is clicked
function toMeClick(){
var ajax = new GlideAjax('u_AssignUser');
ajax.addParam('sysparm_name','u_assignToUser');
ajax.addParam('sysparm_assignment_group', g_form.getValue('assignment_group'));
ajax.getXML(doSomething);
function doSomething(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('assigned_to', g_user.userID);
g_form.setValue('assignment_group',answer);
//g_form.setValue('assigned_to', g_user.userID);
}
}
function doSomething(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2013 12:58 AM
Hi Tom
I tried your code but couldnt get it to work, am i missing something obvious ?
Created the icon
Created the client script
Icon appears next to field
Click - does nothing
Syntax check of the code says Eval is Evil??