How to create Survey Button on incident form

Chaitanya Redd1
Tera Guru

Hello Team,

Please help me on this issue creating Survey button incident form.

  1. I have created Survey Button on incident form but it's not triggering the survey. I have written script and condition but not working.
  2.  I wanted this button should visible only when state is closed and visible only for ITIL users.

Condition : current.active && (gs.hasRole("itil") || gs.hasRole("admin"))

Script :

var typeSysID = '99471f319f0312006371f84bc42e70f1';  //The sys_id of the metric type or survey definition to generate assessments or surveys for.

var sourceRecordID = ' ';  //Actually just leave this as an empty string

var userID = current.caller_id.sys_id; //One or more comma-separated sys_ids of users to send assessment or survey instances to. If this parameter is left blank, the assessment stakeholders or survey users receive instances. This parameter is required for on-demand assessments.

var result = new SNC.AssessmentCreation().createAssessments(typeSysID, sourceRecordID, userID);
asmtGR.get(result.split(",")[0]);

asmtGR.setValue('trigger_id',current.getValue('sys_id'));

asmtGR.setValue('trigger_table','incident');

asmtGR.update();

 

Thanks.

1 ACCEPTED SOLUTION

Chaitanya Redd1
Tera Guru

Hello team,

I have tried below script it worked for me.

var gr = new GlideRecord('asmt_assessment_instance');
gr.addEncodedQuery('metric_type=99471f319f0312006371f84bc42e70f1^user='+current.caller_id+'^trigger_id='+current.sys_id); //Here in the metric_type add the sys_id of your Survey from 'asmt_metric_type' table
gr.query();
if(gr.hasNext()){
gs.addErrorMessage("Surevy already sent to user!");
//current.setAbortAction(true);
action.setRedirectURL(current);
}else{
var Link =(new sn_assessment_core.AssessmentCreation()).conditionTrigger(current,'249e70b0875013005d90bba826cb0bbf');
gs.addInfoMessage(" successfully assigned survey to caller");
action.setRedirectURL(current);
}

 

Thanks all for your help.

 

Thanks,

JRY

View solution in original post

7 REPLIES 7

Hi Ankush,

Can you help me how to trigger survey with event and records should be inserted  

Chaitanya Redd1
Tera Guru

Hello team,

I have tried below script it worked for me.

var gr = new GlideRecord('asmt_assessment_instance');
gr.addEncodedQuery('metric_type=99471f319f0312006371f84bc42e70f1^user='+current.caller_id+'^trigger_id='+current.sys_id); //Here in the metric_type add the sys_id of your Survey from 'asmt_metric_type' table
gr.query();
if(gr.hasNext()){
gs.addErrorMessage("Surevy already sent to user!");
//current.setAbortAction(true);
action.setRedirectURL(current);
}else{
var Link =(new sn_assessment_core.AssessmentCreation()).conditionTrigger(current,'249e70b0875013005d90bba826cb0bbf');
gs.addInfoMessage(" successfully assigned survey to caller");
action.setRedirectURL(current);
}

 

Thanks all for your help.

 

Thanks,

JRY

Hi Chaitanya,

I was trying the above code, could you please let me know from where have you taken the second sys_id (249e70b0875013005d90bba826cb0bbf) from?

Thanks