- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
I have a custom table with certain user details on, that I want to use to create an incident for that user - using those details to populate the caller_id field.
When I use the name field, then it would work fine:
var inc = new GlideRecord('incident');
inc.initialize();
inc.caller_id = current.u_name;
But I realise that the name may not be unique on the sys_user table.
I also have their user_id which would be unique, but changing the script to this, doesn't work.
inc.caller_id = current.u_user_id;
I am sure I am missing something that I could use to achieve this?
Thank you,
Dan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Try below,
var myName='abel.tuter';
var myUser = new GlideRecord('sys_user');
myUser.addQuery('user_name','=',myName);
myUser.query();
while(myUser.next())
{
inc_name=inc.user_name;
var inc = new GlideRecord('incident');
inc.description='Test Incident using User ID';
inc.short_description='Test Incident using User ID from sys_user record';
inc.caller_id=myName;
inc.impact=3;
inc.urgency=3;
inc.insert();
}
If this helped to answer your query, please accept the solution and close the thread.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Try below,
var myName='abel.tuter';
var myUser = new GlideRecord('sys_user');
myUser.addQuery('user_name','=',myName);
myUser.query();
while(myUser.next())
{
inc_name=inc.user_name;
var inc = new GlideRecord('incident');
inc.description='Test Incident using User ID';
inc.short_description='Test Incident using User ID from sys_user record';
inc.caller_id=myName;
inc.impact=3;
inc.urgency=3;
inc.insert();
}
If this helped to answer your query, please accept the solution and close the thread.
Thanks,
Bhuvan