AssessmentCreation - Global - Using Business Rule

Community Alums
Not applicable

Hi All

I do have a survey definition and I am looking to generate assessment record for the required transaction record using script (BR).

 

(new SNC.AssessmentCreation()).createAssessments('8ac4eeaddb3b9d903b8ad8e4e29619f7', // sys_id of the survey definition
      '024b223f977a5558b8d6b87e6253afe5', // sys_id of the transaction record (Ex: sys_id of the IMS record)
      '79eeb230db93b7004868776b8c96197d'); // sys_id of the intended user account

 

When I execute the above statement in script background then facing below error:

 

[AssessmentCreation - createInstances_Parameters]: For assessment f64dcf661bce2cd02a75caee034bcb1a, for user 79eeb230db93b7004868776b8c96197d, instance is not created. Possible reasons are:
1. Please make sure that at least one metric category has at least one assessable record associated.
2. Please make sure that at least one metric category has at least one metric.
3. Please make sure that if domain plugin is installed, at least one assessable record is visible to this user.
4. Please make sure that at least one metric category is accessable to this user - check the roles on category.
5. Please make sure that this user has required roles to access the assessable record.: no thrown error
[AssessmentCreation - createInstances_Parameters]: For assessment f64dcf661bce2cd02a75caee034bcb1a, for following users [79eeb230db93b7004868776b8c96197d], no instance is created. Please find previous error messages for details.: no thrown error

 

I checked the below threads:

AssessmentCreation - Global (servicenow.com)

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0961711

https://www.servicenow.com/community/now-platform-forum/trying-to-generate-surveys-from-business-rul...

And also i am expecting that transaction record (sys_id that is passed as second parameter in the above statement) would be captured on the Trigger ID field on the asmt_assessment_instance table.

RaghavendraMud_0-1671630629561.png

I am clueless where I am going wrong.

Could you please help me in getting this issue fixed.

 

Thanks,

Raghu

 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

HI Case and community thread "Create User Survey" UI Action helped to resolve this issue.

//FIRST HALF SCRIPT - To create assessment instance record

var typeSysID = '8ac4eeaddb3b9d903b8ad8e4e29619f7';//The sys_id of the assessment, should be in published state 
var sourceRecordID = '';//sys_id of the transaction record (Ex: sys_id of the IMS record)
var userID = '79eeb230db93b7004868776b8c96197d'; // sys_id in the opened_by field 
var result = new SNC.AssessmentCreation().createAssessments(typeSysID, sourceRecordID, userID); // successfully created the Survey instance record 
//gs.print('result: '+ result ); 

//SECOND HALF SCRIPT - To associate Tirgger id and Trigger table fields (In the current sceneraio it is INTERACTION)

var asmtGR = new GlideRecord("asmt_assessment_instance"); 
asmtGR.get(result.split(",")[0]); // gets the sys_id of the newly created assessment record from the 'result' variable array 
asmtGR.setValue('trigger_id','052814938703b450ca4b86ae8bbb3509');// links the Interaction record sys_id 
asmtGR.setValue('trigger_table','interaction'); 
asmtGR.update();

 

View solution in original post

1 REPLY 1

Community Alums
Not applicable

HI Case and community thread "Create User Survey" UI Action helped to resolve this issue.

//FIRST HALF SCRIPT - To create assessment instance record

var typeSysID = '8ac4eeaddb3b9d903b8ad8e4e29619f7';//The sys_id of the assessment, should be in published state 
var sourceRecordID = '';//sys_id of the transaction record (Ex: sys_id of the IMS record)
var userID = '79eeb230db93b7004868776b8c96197d'; // sys_id in the opened_by field 
var result = new SNC.AssessmentCreation().createAssessments(typeSysID, sourceRecordID, userID); // successfully created the Survey instance record 
//gs.print('result: '+ result ); 

//SECOND HALF SCRIPT - To associate Tirgger id and Trigger table fields (In the current sceneraio it is INTERACTION)

var asmtGR = new GlideRecord("asmt_assessment_instance"); 
asmtGR.get(result.split(",")[0]); // gets the sys_id of the newly created assessment record from the 'result' variable array 
asmtGR.setValue('trigger_id','052814938703b450ca4b86ae8bbb3509');// links the Interaction record sys_id 
asmtGR.setValue('trigger_table','interaction'); 
asmtGR.update();