Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Schedule an assessment to be sent every quarter

joshmorris
Tera Guru

Im trying to schedule a assessment to be sent every quarter. I have set up the assessment and also the scheduled job but it doesn't seem to send at all. Can anyone help?

 

joshmorris_0-1763466141016.png

joshmorris_1-1763466155047.png

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@joshmorris 

assessment has to be created against some record.

in your script you are just calling the API with survey sysId but no GlideRecord object

try this in background script and then add this logic in scheduled job which runs quaterly

triggerSurvey();

function triggerSurvey() {
    try {
        var gr = new GlideRecord("core_company");
        gr.addEncodedQuery("Your Query");
        gr.query();
        while (gr.next()) {
            new SNC.AssessmentCreation().createAssessments('Survey Definition SysId', gr.getUniqueValue(), 'Your User Sys ID to whom it has to go');
        }

    } catch (ex) {
        gs.info(ex);
    }
}

💡 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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@joshmorris 

assessment has to be created against some record.

in your script you are just calling the API with survey sysId but no GlideRecord object

try this in background script and then add this logic in scheduled job which runs quaterly

triggerSurvey();

function triggerSurvey() {
    try {
        var gr = new GlideRecord("core_company");
        gr.addEncodedQuery("Your Query");
        gr.query();
        while (gr.next()) {
            new SNC.AssessmentCreation().createAssessments('Survey Definition SysId', gr.getUniqueValue(), 'Your User Sys ID to whom it has to go');
        }

    } catch (ex) {
        gs.info(ex);
    }
}

💡 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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader