AssessmentUtils().createAssessments returns 'noquestions'

JeremiP
Tera Guru

Since we're not able to set a new Survey Trigger to use the sn_customerservice_case's Customer field value - its referencing a table that's not extended from sys_user - we decided to go for a business rule that'd create a notification and create a survey instance without an assignee instead.

The issue is that the code below in an async business rule running on abovementioned table, with the condition to run after the case is on state closed:

(function executeRule(current, previous /*null when async*/) {

	var delay = new GlideDateTime();
	delay.addSeconds(15); //number of seconds to delay the notification for the survey by
	var surv = new global.AssessmentUtils().createAssessments('6ef47b1cdb62e340f7c38a3a48961931', current);
	if (surv.indexOf(',') > -1) {
		surv = surv.split(",")[0];
		gs.eventQueueScheduled('sn_customerservice.case_survey_notificat', surv, current.sys_id, (current.consumer || current.contact), delay);
	}
	else gs.info("Creating a survey failed: "+surv+" for case record: "+current.sys_id);


})(current, previous);

Returns an error message: 'noquestions' for the createAssessments function on each of my attempts.

Going by the SN docs I'm not sure what's wrong [since this error message is not mentioned], since the survey actually does have questions:

find_real_file.png

Trying to run the same line for survey instance creation in background scripts, but trying to use the 'AssessmentCreation' object/class as they specify in the documentation above tells me that such a function does not exist.

And so running any of the below lines (with proper parameters) doesn't work out either:

  • global.AssessmentCreation().CreateAssessments(x,y,z)
  • global.AssessmentCreation.createAssessments(x,y,z)
  • AssessmentCreation().CreateAssessments(x,y,z)
  • AssessmentCreation.createAssessments(x,y,z)

Could this have something to do with scopes, or is this doc incorrect for some reason? I'd be grateful for hints or pointers in the right direction.

8 REPLIES 8

Ive been busting my head around this and removing the 'sourceID' did it for me! Thanks Josh!

I had an equally head-busting time tracking this down. Glad to have helped!

Thanks,

Josh

Well now the trigger id isnt being set. 😞 

So I am back to square one. Any advice?

Etienne Galea M
Tera Contributor

Make sure that the filters in the metric def and the filters in the Assessment category are the same.