create incident via workflow

vinod8008
Kilo Explorer

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.

23 REPLIES 23

Harish Ragz
Kilo Guru

Are you capture the two field details from sc_task table?. If yes you can achieve this by creating a Business Rule.

Create a business Rule on SC_TASK table.

var gr = new GlideRecord('incident');

gr.initialize();

gr.short_description = current.short_description;

gr.description = current.description;

gr.insert();

Archana Reddy2
Tera Guru

Hi Vinod,

You need to use current  object in the run script activity.

var inc = new GlideRecord('incident');
inc.initialize();
inc.short_description = current.value_of_field1;
inc.description = current.value_of_field2;
inc.insert();

And, the workflow should be created on sc_task table.

Mark the answer as Correct/Helpful based on the impact.

Thanks,

Chappidi Archana

vinod8008
Kilo Explorer

hello Archana

we create a workflow on sc_req_item, and I write the script in Run Script to create an incident ticket, but the short description value in

the script is static, we want to make it dynamic.

gr.short_description = 'Printer is broken again';

find_real_file.png

 

ThankQ

Hi,

You want to fill the short description of incident dynamically based on which field on which table?

If the field is from sc_req_item table, you can use the script I posted in the previous reply.

Let me know if the field is not from sc_req_item table.

Thanks,

Chappidi Archana