Constructing Tiny URLs

rickseiden_info
Giga Contributor

Hello,

I know that ServiceNow has a Tiny URL plugin that is supposed to shorten URLs, but I'm wondering if there is a way I can feed it a long URL and have it kick out a shortened URL that I can then pass along to someone.

Our SharePoint team is going to be linking to our Service Catalog.   To point to one catalog item in particular, the link is:

https://instance.service-now.com/com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=f220137...

That link is over 255 characters long, and therefore too long for SharePoint (according to our SharePoint team). Our SharePoint team got around this by using goo.gl to shorten the URL.   But management is afraid that when users hover over the link, they'll see the goo.gl URL and be afraid to click on it because it's not an internal or ServiceNow link.

I'd like to know if there is a way that I can manually create a Tiny URL version of that long URL that starts with the instance url:

https://instance.service-now.com/

Thanks

Rick Seiden

1 ACCEPTED SOLUTION

rickseiden_info
Giga Contributor

I managed to do it with Processors (System Definition > Processors).



I created a new Processor of type Script, and put the shortened URL in the "Path" field.   Then I put the following code in the script:



(function process(g_request, g_response, g_processor) {


g_processor.redirect('com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=d38771f4db10c740a47ffb051d961959&sysparm_link_parent=b00565b8dbdc8740a47ffb051d961977&sysparm_catalog=e0d08b13c3330100c8b837659bba8fb4&sysparm_catalog_view=catalog_default');



})(g_request, g_response, g_processor);



It was that "g_processor.redirect(URL)" function that did the trick.


View solution in original post

10 REPLIES 10

Hi Rick, I have a similar need, but my url is being returned back to a client script from a script include, so its not known prior. Do you know of a way to call the processsor dynamically from a client script or a script include?

 

Thanks

Because processors are deprecated in Paris, I was curious if there is a way to accomplish this using the supported feature of Scripted REST APIs. We have yet to deploy to production, and we don't want to start down a path using a deprecated feature (processors), if possible.

Our use case is that we have published and marketed many short URLs in our current environment, pre-ServiceNow (e.g. https://askit.ttu.edu/phishingexamples). They are much simpler for customers to type, agents can remember them easily, and they are guessable. Most of them link to common KB solutions, while a few redirect to a website of our choice. We need all of these existing URLs to continue working when we move to ServiceNow. This askit.ttu.edu hostname will be our service portal address in ServiceNow.

Our current environment accomplishes this using Tomcat URL rewrite rules.

We plan to use the custom URL feature for our ServiceNow instance so that we keep the host name the same, and for the exact paths the solution above was tested by us and works great.

From reviewing the documentation about Scripted REST APIs, it seems like we don't have full control over the exact URL.

Can anyone help with this?

ServiceNow depreciated processors and suggests using the Scripted REST API instead, but as you said, the Scripted REST API doesn't let you have control over the entirety of the URL. 

 

Unfortunately, I don't know of any other way to do it.

 

My suggestion would be to contact ServiceNow support to see if they have a recommendation, as this might be considered a loss of a feature.

 

Good luck.

It turns out that we were able to do this using UI Pages. Here's what it looks like if we want to direct ourdomain.edu/onedrive to a KB solution about OneDrive for Business:

find_real_file.png

Angelo Celeri
Kilo Explorer

Hi, 

 

We need to shorten a link that is being delivered to a list report, would this work? Now we have a link being delivered but its way to long. 

 

Please help!