- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 08:58 AM
We have a timing (?) problem when retrieving the results of an employee form from "asmt_metric_result".
The scenario:
- An HR Task of type "collect employee info" is created
- The employee form contains 3 questions with metric datatype "String" and 1 question with metric datatype "attachment" - all questions are mandatory
- An async Business Rule is triggered when the HR Task changes to "closed complete"
- The Business Rule retrieves the result records from "asmt_metric_result" and does its magic
This works on a PDI, but on our DEV instance we are encountering...
The problem:
- we are unable to retrieve all results because the records on "asmt_metric_result" don't exist yet when the task is completed
- to verify, we are calling two GlideAggregates when our BR fires - one counts records on "asmt_assessment_instance_question", the other on "asmt_metric_result"
- there should be one result record for each question record, that is: 4 questions and 4 results
- however, we're seeing 4 questions records and 1 result record - this is always the "attachment" question
What is causing this delay in the creation of the records on "asmt_metric_result"?
How can we know when to collect the results, if not by looking at the state of the parent task?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 09:17 AM
Hi, a quick follow up: We opened a case with ServiceNow regarding this behavior, and the outcome was: That's just how it is designed. In other words, if you want to know when all results for an assessment have been written, you're out of luck. There's no state change you can watch, and no events are emitted.
Our solution to this was to move the actions we want to perform on the results to a Flow - which creates so much overhead that by the time our Flow action triggers, all results have been written. This might fail if you have an assessment with a large number of questions, but it's the best option you have.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 09:33 AM
@Michael Nau is it creating after some time or the questions are not created at all ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 12:06 AM - edited 08-25-2023 12:07 AM
Yes, the Results are created - at the very same second! All records (task, questions, results) have the same created / updated timestamp afterwards, so this is really just a matter of milliseconds. I have found some community content pointing to similar problems in earlier versions, I am going to investigate further...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 03:56 AM
Another try - moved the BR to "asmt_assessment_instance" with a trigger on "state changes to complete". This gives the same result, when the survey instance completes, the results aren't ready. Very unfortunate behaviour.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 04:32 AM
I'm pretty sure that this is the culprit. Whatever this locked down script include is doing, it's taking longer on a customer instance (on which I am the only active user at this moment) than on my PDI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2023 04:00 PM
If that is the case, why not add an event at the end of that BR so that you can trigger your own processing off the back of it being done?