How to check survey to finish and add that condition to workflow?

Enkhdalai
Tera Expert

Hello guys, 

 

I have a requested item and in stage 1 it creates catalog task. In the catalog task I have configured a survey.

 

In the requested item workflow I need to check surveys to finish and automatically close that task. 

 

Currently I added wait for condition after catalog task creation script and it stuck on the wait for condition. 

 

Here is my wait for condition script. 

 

// Set the variable 'answer' to true or false to indicate if the condition has been met or not.

//New employee first day questionnaire (Requester)
var metricType = 'd039d2d4db5c9d102439aa4dd39619bb';


var grInstance = new GlideRecord('asmt_assessment_instance');

grInstance.addQuery('trigger_id', current.sys_id);
grInstance.addQuery('metric_type', metricType);
grInstance.addQuery('state', 'complete');

grInstance.query();

if(grInstance.hasNext()){

answer = true;

}

else{

answer = false;

}

7 REPLIES 7

Hello,

 

Just to be sure you have applied the other condition as correct. Can you apply the add query filters in the filter of asmt_assessment_instance table and check the the filter actually gets you the correct survey result

Hello, Saurav11, 

I think grInstance.addQuery('trigger_id', current.sys_id); line is failing at getting sys_id of RITM. 

I have tried to set sys_id to var sysid and tried this version:

var metricType = 'd039d2d4db5c9d102439aa4dd39619bb';
var sysid = current.sys_id; 
	current.work_notes = sysid +'';

var grInstance = new GlideRecord('asmt_assessment_instance');

   grInstance.addQuery('trigger_id', sysid);
   grInstance.addQuery('metric_type', metricType);
   grInstance.addQuery('state', 'complete');

grInstance.query();

if(grInstance.hasNext()){
	
	answer = true;
	
}

else{
	
	answer = false;

}

Hello,

 

Is it working now? can you apply log and check if sysid is getting printed correctly?