- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2020 05:02 AM
Hello Team,
Please help me on this issue creating Survey button incident form.
- I have created Survey Button on incident form but it's not triggering the survey. I have written script and condition but not working.
- 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 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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2020 04:08 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2020 05:16 AM
Hi,
In UI action condition
try this,
current.state=='7' && (gs.hasRole("itil") || gs.hasRole("admin"))
//here 7 is value of close state
Thanks,
Kunal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2020 05:29 AM
your script worked to hide and visible only for itil users but survey is not getting triggered after click on survey button. Can you help how to set that issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2020 09:04 PM
hi,
Click on the "View Survey URL" Link
After you have this, you can use the action.setRedirectURL call in ServiceNow.
Example (Takes you to the OOB Service Desk Satisfaction Survey):
action.setRedirectURL('/nav_to.do?uri=assessment_take2.do%3Fsysparm_assessable_type=502a2c44d7211100158ba6859e6103a3');
Please Mark it Correct/Helpful if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2020 06:26 AM
Hi Ankush,
I have tried but it's still not triggering survey once I click on " Survey" button.
Can you please look into below script and help if any changes required.
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();