Multiple assessments for each demand - how to wait for all to be complete until moving to next state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 12:22 PM
Hello,
I have 2 assessments for each demand created. One is new that I just added.
Prior to adding the new assessment, once the existing assessment is complete, the DEmand moves to Qualified state.
Now that have added an additional assessment, I want BOTH assessments to be complete before moving to Qualified state.
The way it's working now is if the existing asessment is closed, the demand goes to Qualified without waiting for the new 2nd assessment to be taken.
This is the business rule that controls this - but I am not sure how to add the logic to check that ALL assessments for this record are complete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 05:09 PM - edited 08-10-2023 07:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 06:13 PM
Hi @Tushar , thank you so much for responding.
I am not sure where to add this logic, since the current business rule calls a script includes:
The condition is:
current.state == 'complete' && current.metric_type == '0556fa9a8f12110040f82ab2f0f923f8'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 07:25 PM
Hi @SandyL83
I guess you should modify the script include method to incorporate the assessment completion logic.
Steps -
Open the script include DemandUtil and locate the method checkAndUpdateDemandIfAssessmentsComplete.
Modify the method to include the assessment completion checks.
Below is an example of how the method might look after modification -
var DemandUtil = Class.create();
DemandUtil.prototype = {
initialize: function() {},
checkAndUpdateDemandIfAssessmentsComplete: function(demandSysId) {
var demand = new GlideRecord('demand_table_name'); // Replace 'demand_table_name' with the actual table name
if (demand.get(demandSysId)) {
var assessment1Complete = demand.assessment1_field == 'Complete';
var assessment2Complete = demand.assessment2_field == 'Complete';
if (assessment1Complete && assessment2Complete) {
demand.state = 'Qualified';
demand.update();
}
}
},
type: 'DemandUtil'
};
Replace demand_table_name with the actual name of your demand table and adjust assessment1_field and assessment2_field to your field names that store the assessment status.
Save the modified script include.
With this approach, the business rule will continue to call the same method, but the method itself now checks the assessment completion status and updates the demand's state to 'Qualified' only if both assessments are complete.
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2023 05:47 AM
Hi sorry for the delay -
i actually tried to update the business rule and do it that way..
Here is what I have, but I can't get it to work...
any ideas?
var gr = new GlideRecord('asmt_assessment_instance');
gr.addQuery('task_id', current.task_id);
gr.addEncodedQuery('stateINcomplete');
gr.query();
if (gr.getRowCount > 2) {
while (gr.next()) {
var dmn = new GlideRecord('dmn_demand');
dmn.addQuery('sys_id', current.task_id);
dmn.query();
while (dmn.next()) {
gr.state = "Qualified";
gr.update();
}
}
}