Survey not creating through createAssessments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 04:30 PM
I have created a survey without trigger condition as I have to trigger a survey against asset on demand through schedule job. when I execute below script using createAssessments() function it is not creating assessment instance below is the return exception message.
script-
For assessment 516c8a439312311060ad3aaefaba10e5, for user 6816f79cc0a8016401c5a33be04be441, 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 516c8a439312311060ad3aaefaba10e5, for following users [6816f79cc0a8016401c5a33be04be441], no instance is created. Please find previous error messages for details.: no thrown error
Please help me understand why survey is not getting triggered and what needs to be changed.
- Labels:
-
Survey Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 05:32 PM
Hi @nikhil2810
As you said, you are running this code through a Scheduled Job, using gs.getUserID() will cause the user ID to be any one of,
- The Run as User of scheduled job
- If the Run as user is empty in the scheduled job configuration it will take system user
- If the scheduled job is ran by clicking Execute Now, it will take user who clicked that button
To test it properly, pass the sys_id of a user who have access to the asset record you are passing ( sys_id of the assigned_to user of that asset record).
And also capture the return results using a variable and print it to system logs to see the exact error code.
So your script will be like this,
var asmnt_res = (new SNC.AssessmentCreation()).createAssessments('516c8a439312311060ad3aaefaba10e5', //sysid of survey '13c1fa8837f3100044e0bfc8bcbe5d38' // sysid of source asset record, "43d1fa8837f3100044e0bfc8bcbwr567"//assign to user sys_id);
gs.info("Assessment Creation Results:" + asmnt_res);
The parameters used here are,
- Sys ID of survey
- Sys ID of asset record
- Sys ID of Assigned to user of the asset record.
If you get the correct results by running this, you can pass the asset record and user sys ID dynamically by querying the recordas using GlideRecord.
Please mark my answer helpful and accept as solution if it helped you 👍✅
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 01:09 PM
Hi @AnveshKumar M ,
I still get the same exception message and no survey instance getting created.