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 07:46 PM
I remove getValue and run the script same problem appears values are not captured

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2018 09:47 PM
Vinod,
Since we are creating workflow for sc_req_item table, the workflow runs based on the insertion/updation made to this table(as far as I know).
But, we wanted to get data from sc_task table. That means, the insertion is done at sc_task table.
If I am not wrong, we need to have this Run Script activity on sc_task table and I have tried with the below code. It worked good.
-------------------------------------------------------------------
var req_item = new GlideRecord('sc_req_item');
req_item.addQuery('sys_id',current.request_item);
req_item.query();
if(req_item.next())
{
var inc = new GlideRecord('incident');
inc.initialize();
inc.short_description = current.short_description;
inc.insert();
}
-----------------------------------------------------------------------
Let me know how far did this help you.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2018 08:30 AM
Hi Archana,
the following script is tested in scripts background it create incident ticket
var task = new GlideRecord('sc_task');
task.addQuery('number','SCTASK0010167');--How to capture this number dynamically
task.addQuery('request_item',"e8a8d83bdb21d3002c885901cf9619d4");
task.query();
while(task.next())
{
var inc = new GlideRecord('incident');
inc.initialize();
inc.short_description = 'hhh';
inc.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2018 08:39 AM
current.number is not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2018 09:17 AM
Vinos,
You should not use current.number, use current.request_item since your query is to look for the parent of sc_task which is sc_req_item.
So, use the code from the previous reply in the workflow created on sc_req_item.
Hope this helps.
Thanks