The CreatorCon Call for Content is officially open! Get started here.

Scheduled Job remains in 'Ready' state only

stormy 12
Tera Contributor

Hello Everyone ,

I have created one On-Demand scheduled job . The goal is to fetch data from ultipro and update HR profiles.

But issue is when I click on Execute Now button , the job is not running. I have check state of schduled job , It shows its state as 'Ready' in Red color even after excuting it.

However the logs that I have added in schduled job are printing in logs.

I am not getting  whether Schduled job is running or not. If runnning why the state is ready? If logs are printing then why profile are not getting update?

Can anyone give solution for this? 

Thank You!

3 REPLIES 3

Harish KM
Kilo Patron
Kilo Patron

Can you share the script of schedule job? may the job is running just not updating this may b due to errors in script. is your log printing the output u needed?

Regards
Harish

Hii Harish

Thanks. Here is script :

var page = 1;

do {

    try {

        var r = new sn_ws.RESTMessageV2('sn_hr_core.UltiPro Person Details', 'Default GET');
        r.setStringParameterNoEscape('per_Page', 100);
        r.setStringParameterNoEscape('page', page);

        var responsePerson = r.execute();
        var responseBodyPerson = responsePerson.getBody();
        // gs.info("responseBodyPerson==" + responseBodyPerson);
        var respPerson = JSON.parse(responseBodyPerson); 
        gs.info("respPerson==" + JSON.stringify(respPerson));
        //         gs.info("page is==" +page);


        for (var i = 0; i < respPerson.length; i++) {

            var grHrProfile = new GlideRecord('sn_hr_core_profile');

            grHrProfile.addQuery('u_employee_id', respPerson[i].employeeId);
            grHrProfile.addQuery('user.active', true);
            grHrProfile.query();
            // gs.info("countis==" + grHrProfile.getRowCount());
            while (grHrProfile.next()) {
                //gs.info('Active user in ultipro '+ respPerson[i].employeeId);


                // Update Personal Email    
                if (respPerson[i].emailAddressAlternate != '') {
                    grHrProfile.personal_email = respPerson[i].emailAddressAlternate;
                    //gs.info('Update email is in if'+grHrProfile.personal_email);
                } else if (respPerson[i].emailAddressAlternate == '' && respPerson[i].emailaddress.indexOf('@gmail.com') == -1) {

                    grHrProfile.personal_email = respPerson[i].emailaddress;
                    //gs.info('Update email is '+grHrProfile.personal_email);
                }

 

                grHrProfile.setWorkflow(false);
                grHrProfile.update();

 

            }
        }

 

    } catch (ex) {
        var messagePerson = ex.message;

    }
    page++;

    var length = respPerson.length;
    //gs.info("length=="+length);


} while (respPerson.length > 0 || typeof length === "undefined");

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

if the logs in job script are shown then it means the job ran

Now next task is to debug

1) if the REST Call is happening or not

2) if the response received is correct

3) is the parsing logic working fine

4) your job is in which scope since HR Profile table is in HR Core scope? If same scope then no issue

Regards
Ankur

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