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

Johnnie O_
Kilo Guru

Have you tried passing it the userID parameter as a test? As far as I understand your situation it seems this is required per the documentation "This parameter is required for on-demand assessments"

find_real_file.png

garrett_griffin
Tera Contributor

I dealt with this quite a bit today. In the end, I deduced that I was getting the 'noquestions' error because the Assessable Record entry didn't exist for the record I was trying to create an assessment instance for.

 

So first thing to check -- does an accessable record exist for what you're trying to trigger off? If not, get that created first.

 

--

And in case anyone (like me) is dealing with this in GRC -- make sure your Assessment/Attestation was created *before* the control. The assessable record entry gets created when the control is created. So to debug, try deleting your control and recreating it.

Jag5
Tera Guru

Hi Jeremi,

 

I am seeing the same issue. Did you find any specific solution for this or found any root cause?

 

Best.

Jag.

 

 

Josh Virelli
Tera Guru

Hi Jeremi,

I just ran into the exact same issue, and this appears to be the only post on Community about this, so I wanted to share my experience. I was initially passing in "null" for the "sourceId" parameter and that was what was causing the script to return "noquestions". I'm using the createAssessments function from the AssessmentUtils script include:

createAssessments: function(typeId, sourceId, userId, groupId){
    return (new SNC.AssessmentCreation()).createAssessments(typeId, sourceId, userId, false, groupId);
},

Once I passed in an empty string for that parameter, it was just fine. Doesn't appear that groupId is required either.

i.e.

new AssessmentUtils().createAssessments('b200985adb637b8094bc74dfaa961972','',gs.getUserID())

Maybe this will help someone else!

Thanks,

Josh