We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

regarding Domain Separation scheduled jobs functioning

AleshKumarK
Tera Contributor

I Have requirement to create scheduled job that runs weekly, we have a custom table 'X', in that we have a stage field and last week stage, we have to run scheduled job every Friday , we need to update last week stage. we have a domain separation in our instance. The below script we wrote in our scheduled job script. but we gettting Row Count = 0, and Weekly stage update. Records updated:0. if we uncomment gr.queryNoDomain(); the scheduled job is not executing. COuld you please help me on this

 

(function () {

    var gr = new GlideRecord('table name');
    //gr.queryNoDomain();
    gr.query();
    gs.info('Row Count:'+gr.getRowCount());

    var updatedCount = 0;

    while (gr.next()) {
        gr.setValue('u_last_week_stage', gr.getValue('u_stage'));
        gr.setValue('u_last_week_amount', gr.getValue('u_amount'));
        gs.info('Check while loop');
        gr.update();
        updatedCount++;
    }

    gs.info('Weekly stage update. Records updated: ' + updatedCount);

})();
1 REPLY 1

Ankur Bawiskar
Tera Patron

@AleshKumarK 

make the scheduled job run as a user/service account that has visibility to the required domains

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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