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-27-2018 09:31 AM
Could you elaborate your workflow.Acually the below code is correct. May be some issue is in workflow.
var task = new GlideRecord('sc_task');
task.addQuery('request_item ',current.sys_id);
task.query();
while(task.next())
{
var inc = new GlideRecord('incident');
inc.initialize();
inc.short_description = task.u_my_short_description;
inc.description = task.u_my_description;
inc.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2018 09:28 AM
once try with below script.
var sct = new GlideRecord('sc_task');
var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = sct.short_description;
gr.description = sct.description;
gr.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2018 11:06 AM
Ok, let me check the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2018 11:19 AM
Hi vinod8008,
Using the same example you provided in the question.
You can create two fields in the form or catalog item:
And use current.variables.variable_name to get the value from the form where you are executing the workflow with the Run Script
This way you can made this assignment dynamic.
Let me know if it was helpful.