Populating current user name through UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2010 02:10 PM
I have a UI Action that we use to create a new change record from a problem. Currently, I am populating the change.assigned_to (change owner) value with the current.assigned_to (Problem Owner) value. We now want to populate the change.assigned_to value with the name of the current user. I've tried a few varieties of the g_user property, but no success.
Here are the wiki articles that I have reviewed:
http://wiki.service-now.com/index.php?title=Getting_a_User_Object
http://wiki.service-now.com/index.php?title=GlideUser_%28g_user%29
Here is the code in the UI Action I have right now:
createChange();
function createChange(){
var change = new GlideRecord("change_request");
change.requested_by = current.assigned_to;
change.assigned_to = current.assigned_to;
change.short_description = current.short_description;
change.description = current.description;
change.u_itwr___helpstar = current.u_related_h_s_incidents;
change.u_affected_system = current.u_affected_qd_systems;
change.u_other_affected_system_s_ = current.u_other_affected_system_s_;
change.u_changereason = "Incident / Problem";
//change.cmdb_ci = current.cmdb_ci;
//change.priority = current.priority;
var sysID = change.insert();
createRelationship(sysID,change);
}
function createRelationship(sysID,change){
var gr = new GlideRecord("task_rel_task");
gr.initialize();
gr.parent = sysID;
gr.type = "d80d5ec20a25810200be8bc5e2f64710";
gr.child = current.sys_id;
gs.addInfoMessage("Change " + change.number + " created");
gr.insert();
action.setRedirectURL(change);
//action.setReturnURL(current);
}
Thanks for any help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2010 12:49 PM
Have you tried using, specifically, gs.getUser():
...
change.requested_by = current.assigned_to;
change.assigned_to = gs.getUser();
change.short_description = current.short_description;
...
I believe that should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2010 05:30 PM
Thanks for the info. I made the change and that worked great.