Schedule job not running but the code is working when executed from background scripts

Shrutij11
Tera Contributor

Hi team,

 

I am facing this issue, I have a scheduled job configured to map country field from subscription id through properties file. The schedule job is not running but the same code works when I am running from background script.

 

var subscriptionCountryMap = JSON.parse(gs.getProperty('sn_vul.issuesSubscriptionCountryMap'));
var countryRegionMap = JSON.parse(gs.getProperty('sn_vul.issuesCountryRegionMap'));

var grVulIssues = new GlideRecord('sn_vul_vulnerability_issues');
grVulIssues.addEncodedQuery('u_subscription_id!=NULL');
grVulIssues.query();

while (grVulIssues.next()) {
    var subscriptionId = grVulIssues.getValue('u_subscription_id');
    var countryName = subscriptionCountryMap[subscriptionId];
   
if (countryName && countryName != "")
    {
        grVulIssues.u_wiz_country = countryName;
        grVulIssues.u_wiz_region = countryRegionMap[countryName].location;
        grVulIssues.u_brand_name = countryRegionMap[countryName].brandName;
    }

else {
         grVulIssues.setValue('u_wiz_country', 'UNGROUPED');
     }
    grVulIssues.autoSysFields(false);
//  grVulIssues.setWorkflow(false);
    grVulIssues.update();
}
 
Kindly help me with this.
4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

Is the scheduled job in the Global scope?  Are you running it as the system account or an admin?

it is in global scope and running as system account

 

Try adding some logs to confirm the script is running, see how far it gets, and the values assigned to script variables.  Then you'll see which if conditions are not being met, or where it is going wrong.

Rajesh Chopade1
Mega Sage

hi @Shrutij11

- Ensure scheduled job has the necessary permissions to access the tables and fields being modified.

- Scheduled jobs might run before the properties are properly loaded or updated. Since you’re retrieving mappings from the system properties (gs.getProperty), it’s worth checking if the properties are accessible at the time the job runs.

- Put logs and check, if the property values are null or missing in the logs, check if the scheduled job is running before the properties are set.

 

After the scheduled job runs, review the System Logs under System Logs > All for any potential errors or warnings that could indicate why the job isn't executing as expected.

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

rajesh