Need Background script for changing a field value

AnandKumar1
Tera Expert

Hi Team,

Good Day!!

I need a background script for changing a field (Task type) value (from Test to Post-Work).

We dont have field value in numbers as like in Incident.Attached the screenshots.find_real_file.png

 

find_real_file.png

Please check . the script is not working as it takes any value given other than Test,Work,Pre-Work,Post-Works too.

1 ACCEPTED SOLUTION

AbhishekGardade
Giga Sage

Hello Anand,

We are using IN operator if we want to find numbers from comma separated values provided in query.

For example.

ctask.addQuery('number','CTASK0753800,CTASK0753801,CTASK0753802');

As you need to find it for single ctask, then either you can use addQuery without IN,

var ctask = new GlideRecord('change_task');

ctask.addQuery('number','CTASK0753800');

ctask._query();

if(ctask._next()) {

ctask.u_type="Post-Work";

ctask.setWorkflow(false);

ctask.update();

}

Please mark as Correct Answer and Helpful, if applicable.
Thank You!
Abhishek Gardade

Thank you,
Abhishek Gardade

View solution in original post

5 REPLIES 5

AbhishekGardade
Giga Sage

Hello Anand,

We are using IN operator if we want to find numbers from comma separated values provided in query.

For example.

ctask.addQuery('number','CTASK0753800,CTASK0753801,CTASK0753802');

As you need to find it for single ctask, then either you can use addQuery without IN,

var ctask = new GlideRecord('change_task');

ctask.addQuery('number','CTASK0753800');

ctask._query();

if(ctask._next()) {

ctask.u_type="Post-Work";

ctask.setWorkflow(false);

ctask.update();

}

Please mark as Correct Answer and Helpful, if applicable.
Thank You!
Abhishek Gardade

Thank you,
Abhishek Gardade