how to stop Scheduled jobs getting run using inactive user profile

Vineela1
Tera Contributor

Hi Team,

Scheduled Jobs getting run by inactive user as created by user is inactive when scheduled job is getting run.

Please suggest inputs how to avoid this.

As client project security issues , they don't want to run scheduled jobs if created user is inactive.

 

 

Regards,

Vineela

 

 

 

14 REPLIES 14

Hi @Ankur Bawiskar ,

Please suggest , how we can track scheduled jobs whose created by users are inactive.

Is there any way instead of manual check , any OOTB script is checking on this.

 

Thanks and Regards,

Vineela

@Vineela1 

nope

you need to check manually or write a script to check this.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Phanindra N
Tera Guru

Hi Vineela,

 

The schedule won't run correctly with inactive user in 'Run as' fields, as some access is needed and inactive users doesn't have.

 

I have seen this situation where the scheduled reports are sent out and only some columns are having value and others doesn't. This happens when admin left the project and 'Run as' field value should be updated with replaced user.

 

To overcome this you can add a step before deactivating user ,to check whether the user is in the 'Run as' field for any scheduled job or scheduled reports and alert with a notification or stop deactivating that user with an error message. 

Hi @Phanindra N ,

Please suggest , how we can track scheduled jobs whose created by users are inactive.

Is there any way instead of manual check , any OOTB script is checking on this.

 

Thanks and Regards,

Vineela

Hi @Vineela1 

 

There is no OOB script, we have to write it on your own and have to implement it. Implementation depends on how you are inactivating the user. If manually inactivating client script or business rule will do, if done via any catalog item you have change the workflow.

 

Script would be similar to this:

var gr = new GlideRecord('sysauto');

gr.addEncodedQuery('active=true^run_as='+ [sys_id of user inactivating]);

gr.query();

 

if(gr.next()){

//user is in the 'Run as' field in one or more scheduled jobs or scheduled emails, abort the action and show error message

}