How to create a functioning sys_tiny_url record via script

Not applicable

I am trying to create a tiny URL dynamically via a script and need to know how to get it working.

 

For reference, I tried to follow advice from https://www.servicenow.com/community/developer-forum/how-to-convert-long-url-to-tiny-url-without-pro... but the question remains unsolved.

Any help appreciated!!

2 ACCEPTED SOLUTIONS

Mark Roethof
Tera Patron

Hi there,

 

Can you share what you tried exactly?

 

When I add manually a new sys_tiny_url record, and open it, it works fine.

 

Tiny URL record created:

Tiny URL [tiny_url]: community_test

Data [data]: =active%3Dtrue%5EnumberININC0010048%2CINC0010047%2CINC0010046%2CINC0010045%2CINC0010044%2CINC0010043%2CINC0010042%2CINC0010041%2CINC0010040%2CINC0010039%2CINC0010038%2CINC0010037%2CINC0010036%2CINC0010035%2CINC0010034%2CINC0010033%2CINC0010032%2CINC0010031%2CINC0010030%2CINC0010029&sysparm_view=

 

URL to open:

https://your-instance.service-now.com/now/nav/ui/classic/params/target/incident_list.do?sysparm_tiny...

 

This basically opens a list of incidents, with as query a bunch of incident numbers.

View solution in original post

Thomas Walker2
Tera Guru

Check out the GlideTinyUrl class. Do a code search in your instance and you can find some examples.

For example:

new GlideTinyURL().createTinyURL(url);

or if you always want it to be a tiny url

new GlideTinyURL().createTinyURLWithCustomLength(url, 10);

Pretty sure it is a global only API so you might need to wrap it in a global script include, but thats alot better than making ajax request from the server to the server haha. The default one will use the system property

glide.tiny_url_min_length

to determine when to generate a TinyURL and when to just passthrough the URL.

View solution in original post

3 REPLIES 3

Appli
Giga Sage

Hi, what is your use case, why tiny URLs are required? Please elaborate

Mark Roethof
Tera Patron

Hi there,

 

Can you share what you tried exactly?

 

When I add manually a new sys_tiny_url record, and open it, it works fine.

 

Tiny URL record created:

Tiny URL [tiny_url]: community_test

Data [data]: =active%3Dtrue%5EnumberININC0010048%2CINC0010047%2CINC0010046%2CINC0010045%2CINC0010044%2CINC0010043%2CINC0010042%2CINC0010041%2CINC0010040%2CINC0010039%2CINC0010038%2CINC0010037%2CINC0010036%2CINC0010035%2CINC0010034%2CINC0010033%2CINC0010032%2CINC0010031%2CINC0010030%2CINC0010029&sysparm_view=

 

URL to open:

https://your-instance.service-now.com/now/nav/ui/classic/params/target/incident_list.do?sysparm_tiny...

 

This basically opens a list of incidents, with as query a bunch of incident numbers.

Thomas Walker2
Tera Guru

Check out the GlideTinyUrl class. Do a code search in your instance and you can find some examples.

For example:

new GlideTinyURL().createTinyURL(url);

or if you always want it to be a tiny url

new GlideTinyURL().createTinyURLWithCustomLength(url, 10);

Pretty sure it is a global only API so you might need to wrap it in a global script include, but thats alot better than making ajax request from the server to the server haha. The default one will use the system property

glide.tiny_url_min_length

to determine when to generate a TinyURL and when to just passthrough the URL.