Error in Take Assessment page - unexpected failure with this assessment, invalid type provided
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2023 08:17 PM
I wanted to filter out records in 'View Surveys' page based on department of survey creator. For this, I..
- created a reference field for department
- made a 'insert' business rule which fetches and sets the logged in user's department value. This way I got department value for a few records in 'View Surveys'
- created a simple before query business rule to filter out records based on 'department'
- When ever I apply this filter rule, the records are displayed as intended. But when I try to take a survey or even open the preview page for 'Take Assessment', it throws the above error
If I apply another before query business rule filtering records based on user logged in (as the creator, which does not require newly created fields) everything works correctly. It's only the department rule which is affecting the page
I have attached a few images. Below is the script for department BR. Please help
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', gs.getUserID());
gr.query();
if(gr.next())
{
current.addQuery('u_department', gr.department);
}
})(current, previous);
u_department is the custom reference field I created in 'View Surveys' i.e. asmt_metric_type table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2023 09:38 AM
Did you figure this out? I am getting the same error but I have not done anything just basic, not business rules, etc.
Thanks,
Stacy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2023 12:43 PM - edited ‎03-30-2023 12:47 PM
Hello Stacy,
I figured out a few things. I was applying BR to everyone instead of only to a survey_creator role. The BR used on 'asmt_metric' table is also being applied to the survey preview and take survey pages, since they source data from this table. Survey takers will not be able to access the metric even if they are assigned the survey. Hence the error. I also do not want to modify too much by adding custom fields like department.
I checked out the logic of existing ACLs for 'survey_creator' and they assume that any creator will be a 'survey_owner' since their id is added to the owner list by default (upon creating a survey)
The existing ACLs on different survey tables (mainly asmt_metric_type and asmt_metric_result)already filter out records based on logged in creator. We can simply use these ACLs by adding the department condition here i.e check if the logged in user is of the same department as survey owner for each record.
But problem with using ACLs is
1. They apply condition to each record one by one
2. They display records weirdly in the survey pages. If there are 5 out of 100 records belonging to logged in user, they will display them randomly in spread out pages (even with blank pages) We have to search through those pages to find any record
We can instead use this ACL logic in business rules (match departments of logged in user and survey owner) and display records accordingly. The only catch for Survey Responses page is that we still have to include the department logic in ACL related to 'asmt_metric' table since the questions are sourced from this table. If we don't, there will be blank values for questions in some records not belonging to the user.
Hope this helps. If this is not your scenario, please state yours