How to parse assessment instance url to get the "accessable_type"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2019 07:14 AM
I'm creating an email script to build an assessment link to send users. However, the "no code" way sends users to the platform. This way is hideous and feels odd. We want to send users to the portal's "take_survey" page to complete all assessments.
I understand the below gets me the "no code required" link that does in fact link to the form. That looks like this:
https://instance.service-now.com/nav_to.do?uri=assessment_take2.do%3Fsysparm_assessable_type=e1768da91b54c8904750bbfccd4bcb54%26sysparm_assessable_sysid=b9504f5fdb104410551680f33996194f
AssessmentUtils().getAssessmentInstanceURL(current.sys_id)
The "sysparm_assessable_type" is what I need to build the URL to send our users to the correct place:
https://instance.service-now.com/it?id=take_survey&type_id=e1768da91b54c8904750bbfccd4bcb54
However, no matter what I do to try and get this "sysparm_assessable_type" it renders as "undefined."
Below is the script I last tried to pull it out and I thought for sure it would work, but it's not.
var assessmentURL = new AssessmentUtils().getAssessmentInstanceURL(current.sys_id);
var assessmentSysID = String(assessmentURL).subString(94, 126);
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2019 08:23 AM
FYI - A response to this post was featured on the Community Live Stream video. I invite you to watch the episode.
Video: Community Live Stream - 2019-10-10 - Developer Community - ServiceNow Community

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2019 08:56 AM
Great thank you.
You obviously have a lot of knowledge on ServiceNow and it's workings, however I believe you assumed what I was asking instead of reading.
I didn't ask how to build this URL. I'm asking how to get the value of sysparm_assessable_type from the dynamically built URL to the "Classic UI" into a variable so that I can then build the URL I need.
Using GlideURI sounds like a great idea as I am indeed trying to parse a URL. I do not understand how to get my variable with the URL to parse into the GlideURI and then return my value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2020 02:12 AM
I have the similar issue, Maybe this solution can help you:
var gr = new GlideRecord('asmt_assessment_instance');
gr.addQuery('trigger_id', current.sys_id);
gr.query();
if (gr.next()) {
var instance = gr.sys_id;
}
var record = current.sys_id;
var instancesurvey = gs.getProperty('glide.servlet.uri') + 'sp?id=take_survey&instance_id=' +instance;
template.print(instancesurvey);