Using Survey Question to Trigger Email Notification

rdskn023ET
Tera Contributor

So we have an instance where we use a survey in a demand, as a demand task, and I would like to use one of the question responses to trigger an email notification that includes information on that demand. For instance, when a demand is submitted, a survey is generated. If question one in that survey has the response of Yes, then I want to trigger an email notification to have an email sent out that includes the demand name, demand #, as well as some other information on that particular demand. Has anyone done something like this or can offer any assistance on how to accomplish this? Thanks in advance!

2 REPLIES 2

BharathChintala
Mega Sage

@rdskn023ET  write Business rule on "asmt_assessment_instance" table 

 

condition state changes to Complete.

 

In Script glide "asmt_assessment_instance_question" table query your question in value field you will have user selected answer based on that write your script.

 

 

That is similar to what I initially tried, but was pointing to the metric results table instead of the assessment question table. See below. 

 

var survey = new GlideRecord('asmt_metric_result');
survey.addQuery('instance', current.sys_id);

surveyaddQuery('metric', '96bf48f11b05a5100ec232231b4bcbaf');
survey.query();

if (!survey.nil()) {

var input = survey.string_value;
if (input == 'yes') {

gs.eventQueue('BRM_email_trigger', current, gs.getUserID(), gs.getUserName());
}
}

 

Then, on the email notification that is fired from the event, I just used the Demand table and entered the fields from the demand I needed to display. It will trigger once I select the proper answer and submit the survey, however, it will not display the correct demand information. It seems to always select a specific demand and display that information. For instance, I can be on Demand123, take the survey, submit and the email notification will display the information for Demand456. Regardless of the demand I take the survey from, it will always display the information from Demand456. Thoughts? Just new to the metric tables and how they interact with the demand table.