- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2021 07:24 AM
Hi
I am looking to create an automation where our User Management team can create an incident to report that a user has left the company. My thoughts were create a button on the User form which can be clicked which does the following:
- Creates a new incident
- Sets the Caller to the users name
- Sets Category and sub category
- Populates the Configuration item to the users assets (Each CI has the assigned to field populated with a users name)
- Enters details into the description field
I have already created the button on the user form but i am unsure how to complete the above actions
Any guides or advise is welcome
Thank you in advance
Adam
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2021 07:39 AM
Bit modification:)
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('assigned_to',current.sys_id);
gr.query();
gr.next();
var inc = new GlideRecord("incident");
inc.initialize();
inc.caller_id = current.sys_id;
inc.category = 'addyourcategory';
inc.subcategory = 'addyoursubcategory';
inc.cmdb_ci = gr.sys_id;
inc.short_description = 'addyourdescription';
inc.insert();
action.openGlideRecord(inc);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2021 07:41 AM
UI Action Script:
var inc = new GlideRecord('incident');
inc.initialize();
inc.caller_id = current.sys_id;
inc.category = 'xyz'; //choice value of category
inc.subcategory = 'pqr'; //choice value of subcategory
inc.cmdb_ci = getAssignedCI(current.sys_id);
inc.insert();
action.openGlideRecord(inc);
function getAssignedCI(user) {
var ci = new GlideRecord('cmdb_ci');
if (ci.get('assigned_to', user)) {
return ci.sys_id.toString();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2021 07:46 AM
Just a tip on these code examples, instead of using something like inc.caller_id = current.sys_id; use inc.setValue('caller_id', current.sys_id); to avoid pass-by-reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2021 10:01 AM
Thank you all for the advise. I added the script and this now working a treat.