Scheduled job to update state field

Service Manager
Kilo Guru

Hi All,

I need help to create a scheduled job to update state field on task table as per the Request state field on Sc_request table.

Suppose if the Request state on Request table is closed complete then update the State field on task to closed completed too.

Scheduled job is to check what all request are not updated correctly and update them.

For instance : we have few Requests records with "Request state" as closed complete but the state field on task table remain "Pending", those request records need to be updated

Thanks!

1 ACCEPTED SOLUTION

1) Before Business Rule

2) Set the conditions as per your query i.e state = -5 and request state is completed in condition builder of business rule

find_real_file.png

3) Try the below script, update as per requirement.

var app=new GlideRecord('YOURTASKTABLENAME');
app.addQuery('number',current.number);
app.query();
if(app.next())
{
//Make use of setWorkflow false if required.
app.state = '3';
app.update();
}
}

Hope this helps!

Please Mark as Correct if this solves your issue and also mark (y) Helpful if it helps resolve your problem.

Thanks,
Saji

View solution in original post

10 REPLIES 10

Yash Agrawal1
Tera Guru

Hello Service MAnager,

You Can also write a business rule which will close the task when you are closing the request. As scheduled job runs on a specified time repeatedly.

Using busing rule ->whenever you are closing request all the tasks will also get closed.

Please keep posted if want code to implement the solution using business rule.

Please Mark it helpful/correct if my answer helps in any way to resolve your query.
Reach out to me if any more help required.

Regards

Yash.K.Agrawal