
- 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
‎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
‎04-12-2018 07:27 AM
Hi JC,
I'm trying to get a similar result so I can add in a link to the Take Survey widget in my resolution notification.
I'm guessing I would need a mail script to look up the 'task_id' from the assessment table before populating the result in the link:
https://mydevinstance.service-now.com/sp?id=take_survey&instance_id=03e83ddbdbdd9b4887e2f3de3b96190c
Would you mind posting your code for the GlideRecord query so I can see if I can achieve a similar result?
Many thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2018 05:27 AM
JC, we are trying to do this same thing. Would you mind posting your code? Thank you!
Susan Williams, Lexmark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2018 03:28 PM
Bumping one more time to see if JC can post his code.
Help us Obi Wan JC - you're our only hope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2021 11:30 PM
Hey did you find any solution?