- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 02:15 PM
Hi All
I need some assitance trying to reslove an issue I have.
I have a some code that is passing data to a script include that is calling servicenow.com/api/now/tinyurl
This works fine and it returns the correct data, as in it is creating a tinyURL instead of the large URL we have. However when passing back to UI action (client) I get the following
{"result":"incident_list.do?sysparm_tiny=bCDZEY6ZdSvvBGHG1ghQbISkFipx04EN"}
I just cannot split the result from the required URL.
Any assistance appreciated.
Thanks
Dave
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 11:27 PM
Hi @newservicenowus :
The result is in JSON format you need to parse it to get the result of the tiny url.
Use the below code snippet to access the value of result
var api_res = response;
var url = JSON.parse(api_res);
alert('URL- '+instnace+url.result);
Mark this as Helpful / Accept the Solution if this clears your issue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 02:51 PM
Hi @newservicenowus ,
What exactly you are expecting in the result and what are you trying to split.
Can you please provide more info so that we could help.
Thanks,
Sanjay Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 11:06 PM
Hi Sanjay
I'm expecting just the last part of the URL - incident_list.do?sysparm_tiny=bCDZEY6ZdSvvBGHG1ghQbISkFipx04EN, so I can build the full tiny URL, getting the instance is fine.
function getURL(response) {
var instance = 'https://' + window.location.hostname + "/";
alert('URL - ' + response);
// var newsrc=instance + 'incident_list.do?sysparm_tiny=bCDZEY6ZdSvvBGHG1ghQbISkFipx04EN';
url = response;
alert('URL- ' + instance + url);
Hardcoding the value works fine, just need the response to remove {"result":
I've tried using JSON.parse but that just gives me object object
Thanks
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 11:27 PM
Hi @newservicenowus :
The result is in JSON format you need to parse it to get the result of the tiny url.
Use the below code snippet to access the value of result
var api_res = response;
var url = JSON.parse(api_res);
alert('URL- '+instnace+url.result);
Mark this as Helpful / Accept the Solution if this clears your issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2024 12:02 AM