Create Incident Task for Incident/Record Producer based on variable from variable set in the record

jbasa
Tera Contributor

For the above question, a group has a record producer related to our conference room.

One question is a Yes/No variable.

If Yes, the goal is to create a new Inc Task and assign it to a group. An alert, if you will.

 

 

1 ACCEPTED SOLUTION

Pushkar-Snow
Mega Guru

Hi @jbasa ,

 

You can write code in the script field for record producer. Below script field will check the variable value and perform login mentioned in the condition.

 

Dummy variable used to explain the script - want_to_book

 

 

Screenshot.png

 

 

 

 

 

 

Script : 

current.short_description = 'Book your Room';
var isTrue = producer.want_to_book;
if(isTrue == "Yes")
{
var grIncTask = new GlideRecord('incident_task');
grIncTask.initialize();
grIncTask.incident = current.sys_id;
grIncTask.short_description = producer.short_description;
grIncTask.assignment_group = '<Sys ID of Group>';
grIncTask.insert();
}

 

If I am able to help you with your question, Please click the Thumb Icon and mark as Correct. 

 

Regards,

Pushkar

View solution in original post

3 REPLIES 3

Pushkar-Snow
Mega Guru

Hi @jbasa ,

 

You can write code in the script field for record producer. Below script field will check the variable value and perform login mentioned in the condition.

 

Dummy variable used to explain the script - want_to_book

 

 

Screenshot.png

 

 

 

 

 

 

Script : 

current.short_description = 'Book your Room';
var isTrue = producer.want_to_book;
if(isTrue == "Yes")
{
var grIncTask = new GlideRecord('incident_task');
grIncTask.initialize();
grIncTask.incident = current.sys_id;
grIncTask.short_description = producer.short_description;
grIncTask.assignment_group = '<Sys ID of Group>';
grIncTask.insert();
}

 

If I am able to help you with your question, Please click the Thumb Icon and mark as Correct. 

 

Regards,

Pushkar

@Pushkar-Snow The variable is part of variable set.  Do I need to remove that variable from the variable set and create it under Variables as shown in your example for this to work?

jbasa
Tera Contributor

My bad, mine was a select box not Yes/No.