Trigger Demand Assessment when state moves to Submitted
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2023 09:47 AM
We're exploring having our Demand Assessments trigger when the demanding state moves to Submitted instead of Screening in order to better match our internal procedures.
I'm hoping someone can validate my work hear and make sure I'm not overlooking something. Our Demand states are OOB. Here are the state values for quick reference:
Value | Label | Sequence |
1 | Draft | 1 |
2 | Submitted | 2 |
3 | Screening | 3 |
'-4 | Qualified | 4 |
5 | Incomplete | 5 |
10 | Deferred | 6 |
7 | Rejected | 7 |
8 | Approved | 8 |
9 | Completed | 9 |
I believe this can be done by modifying the checkAndUpdateDemandIfAssessmentsComplete function in the DemandUtils script include in the following way.
Original:
checkAndUpdateDemandIfAssessmentsComplete : function(instanceSysId) {
var gr = new GlideRecord('asmt_assessment_instance_question');
gr.addQuery('instance', instanceSysId);
gr.query();
if (gr.next()) {
var questionGR = new GlideAggregate('asmt_assessment_instance_question');
questionGR.addQuery('source_id', gr.getValue('source_id'));
questionGR.groupBy('instance');
questionGR.query();
while (questionGR.next()) {
if (!(questionGR.instance.state == 'complete' || questionGR.instance.state == 'canceled'))
return false;
}
// All assessments completed
var demandGR = new GlideRecord('dmn_demand');
if (demandGR.get(gr.getValue('source_id')) && demandGR.state == 3) {
demandGR.state = -4;
demandGR.update();
}
return true;
}
return false;
},
Modified:
checkAndUpdateDemandIfAssessmentsComplete : function(instanceSysId) {
var gr = new GlideRecord('asmt_assessment_instance_question');
gr.addQuery('instance', instanceSysId);
gr.query();
if (gr.next()) {
var questionGR = new GlideAggregate('asmt_assessment_instance_question');
questionGR.addQuery('source_id', gr.getValue('source_id'));
questionGR.groupBy('instance');
questionGR.query();
while (questionGR.next()) {
if (!(questionGR.instance.state == 'complete' || questionGR.instance.state == 'canceled'))
return false;
}
// All assessments completed
var demandGR = new GlideRecord('dmn_demand');
if (demandGR.get(gr.getValue('source_id')) && demandGR.state == 2) {
demandGR.state = 3;
demandGR.update();
}
return true;
}
return false;
},
Additionally, I believe we would need to modify the Create OnDemand Assessment business rule trigger Condition.
Original:
previous.state == 2 && current.state == 3
Modified:
previous.state == 1 && current.state == 2
- Labels:
-
Demand Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 12:35 PM
follow these steps
Open Demand in list
don't touch anything else.
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 09:49 AM
Hi @BharathChintala ,
I changed the condition of Demand metric type, regenerate assessable records, however, it is only working when state changes to screening. For the rest, it is not working, assessment is not calculating.
Do you have any idea?
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 09:49 AM
Hi @An Le,
It's been awhile since I implemented this, but I believe we implemented it exactly as I described in the original post. The trigger for demand assessments don't rely on the Conditions for the Assessment Metric Type.