After the demand assessments are complete, keep the demand in screening.

Karlie
Tera Contributor

Where is the logic that is setting the demand to qualified after the assessments are complete? We want to keep it in screening and manually move to qualify after the scores are reviewed. 

2 REPLIES 2

Adam Geil
Kilo Sage

Hi @Karlie,

 

I believe this is set by the DemandUtils script include, specifically line 37. It's done as part of the function checkAndUpdateDemandIfAssessmentsComplete.


DemandUtils link: https://<YOUR-INSTANCE>.service-now.com/nav_to.do?uri=sys_script_include.do?sys_id=abea62348f72110040f82ab2f0f92314

 

	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;
	},

 

phil bool
Tera Contributor

You've probably heard this kind of feedback a lot, but I'd suggest thinking long and hard before making a change to that script.  This is an example of one of ServiceNow's Out of the Box Script Includes, and when changes are made, they have to be re-made every time you upgrade the platform.  It's manageable, but lots of small changes of this type can quickly lead to problems engaging with new functionality.

Instead, I'd consider looking at your process;  do you actually need to review these records before they go to Qualified?  Is it perhaps more beneficial to look at the qualified records (those that have had all the Stakeholder feedback and are ready for consideration) and if any aren't ready for review by your PMO / Demand Board, passing them back to Draft with notes on the extra information required.  Then the Demand Manager can add extra stakeholders, review feedback, etc., and resubmit as appropriate.