
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2017 10:11 PM
We plan to link to the new Service Portal survey view for our existing surveys and we can't determine how to generate the instance_id on the URL to enable this.
You can already see the Service Portal survey view thru instance.service-now.com/sp?id=my_surveys
Now what we are trying to do is to automatically link the user to the relevant survey of the incident they are in when they click a notification from the mobile app or clicking the Take the Survey link on the email notification.
This is a sample URL of a specific survey that will be shown using the survey view on Service Portal (the part that is bold is the one we don't have an idea on how to generate):
instance.service-now.com/sp?id=take_survey&instance_id=4bb014670f47f2003ba0c19ce1050e28
For the mobile app notification for example, we have setup the following:
(function buildJSON(/*GlideRecord*/ current, /*String*/ message, /*Object*/ attributes) {
var json = {};
json = {
"aps" : {
"sound" : "default"
},
"web_path" : "sp?id=take_survey&instance_id=" + <help needed on this part>
};
return json;
})(current, message, attributes);
Can someone help us determine how to get the sys_id of the survey that is related to current incident so that when user clicks the mobile app notification (or clicks the link on email address) it will show the survey using the Service Portal view.
Thanks.
Solved! Go to Solution.
- Labels:
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2017 07:53 PM
We've found a solution for this after digging around and having discussions with a ServiceNow technician.
The following table stores the assessments: asmt_assessment_instance
If you personalise the list view (https://instance.service-now.com/asmt_assessment_instance_list.do), you can see there is a "Task" and "Trigger ID" column, either of them is what we need to relate the incident that spawned the survey.
Now you can modify the code in your push notification to lookup the survey (return the survey sys_id) from the "Task" that is in the "Current" incident number variable of the push notification code. You can also use the "Trigger ID" and lookup for the "Current" incident sys_id variable of the push notification code.
To do the lookup, you can add code before the "var json = {};" line to lookup the survey record associated to the incident to get the sys_id of the survey using a GlideRecord query: http://wiki.servicenow.com/index.php?title=GlideRecord#addQuery
We just modified the code I have on my original post a bit to do this lookup. Hope this helps for other users on the same situation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2018 12:03 AM
This is what you need to do to direct users to the Portal from Survey link:
/sp?id=take_survey&instance_id=${sys_id}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2019 02:13 PM
Something like this in a mail script may also help if you haven't figured it out by now. This specific mail script is for a notification on the asmt_assessment_instance table. If you wanted to do something on the incident table, then you can do a Glide Record query to this table where current sys_id is trigger_id and get the sys_id of that assessment. Hopefully that makes sense. If not then PM me.
(function runMailScript(current, template, email, email_action, event) {
//get current sys id of assessment
var isys = current.sys_id;
//take survey link where instance id...
var link = 'sp?id=take_survey&instance_id=';
//is the sys_id and have the link say satisfaction survey. Will update to use gs.getMessage later.
var url = '<a href="' + link + isys + '">' + 'satisfaction survey</a>';
template.print(url);
})(current, template, email, email_action, event);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2019 02:09 AM
Hi
I Have a Requirement,i am new to this one - my scenario is once submit the user her survey on portal we want notification with survey responses(Resuls) not any links.
any idea ? please reply me ASAP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2019 08:48 AM
All you need to do is create a notification which has a trigger related to when you want to send your survey. And then potentially create a mailscript that includes the variables/responses you need in there.