- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2016 08:15 AM
I have a Service Catalog item that asks the end user for a secondary email address.
I want a workflow that takes the user's value and inserts it into a field on the user's record. The script below is what I have, but it doesn't populate that user's record. I've tried the glide record functionality and simply copying the variable to the field (hence the commented out portions). What am I missing?
/*var user = new GlideRecord('sys_user');
user.addQuery('name', current.request.requested_for);
user.query();*/
current.request.requested_for.u_email = current.variables.secondary_email;
/*user.u_email = current.variables.secondary_email;*/
gs.log(current.request.requested_for.getDisplayValue() + ' ' + current.request.requested_for.u_email);
//user.update();
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2016 08:23 AM
Hi Michael,
You were close with the GlideRecord query. I would use something like this though:
var user = new GlideRecord('sys_user');
if (user.get(current.request.requested_for)) {
user.u_email = current.variables.secondary_email;
user.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2016 08:22 AM
I believe the problem is that 'name' is a text field on the user's record (calculated from First, Middle and Last) and your searching the 'current.request.requested_for' value which is a Sys_ID to the referenced user record.
Try:
user.addQuery('sys_id', current.request.requested_for.sys_id);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2016 08:23 AM
Hi Michael,
You were close with the GlideRecord query. I would use something like this though:
var user = new GlideRecord('sys_user');
if (user.get(current.request.requested_for)) {
user.u_email = current.variables.secondary_email;
user.update();
}