create incident via workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2018 08:11 AM
We are trying to create an incident via workflow, We have tried using the run script
This is one of the scripts we have tried via the run script activity:
(we found this via the community)
var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = 'Printer is broken again';
gr.description = 'There is something wrong with the printer again, should we get a new one?';
gr.insert();
It is working but how to make the short description and description as dynamic in above script.I create two fields on the sc_task table and how to capture the fields values and set the values to the description and the short description of the incident table while creating a ticket using workflow.
please help me to achieve that task.
ThankQ.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2018 11:12 AM
The field values are not captured in the incident, it shows a blank in short description field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2018 11:14 AM
Can you please paste your code here so that we can help you better.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2018 11:18 AM
here is my code
var task = new GlideRecord('sc_task');
task.addQuery('request_item ',current.sys_id);
task.query();
if(task.next())
{
var inc = new GlideRecord('incident');
inc.initialize();
inc.short_description = task.getValue('u_my_short_description');
inc.description = task.getValue('u_my_description');
inc.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2018 11:20 AM
No need to use getValue here .Use directly task.u_my_short_description.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2018 11:24 AM
Remove getValue from the code and give it a try. This will work.
Mark the answer as Correct/Helpful based on its impact.
Thanks