How to have hyperlink URLs in worknotes with optional parameters (Configurable Workspace)

Diogo Ramos
Giga Sage

Hello, a common usage that we usually have on the work notes is to add a clickable link so the user can open another record whatever that record might be. 

Now the normal way using [code] opens the record correctly as a sub tab of the current record that we are viewing. (I'm aware that not using [code] is part of the security hardening that is not the question here)

DiogoRamos_0-1727700461695.png
--


What I'm trying to achieve is to be able to pass some parameters on this clickable URL so I can use them to show different information when the user opens the necessary record (handling the the parameter in the variant page). I've been trying to search but so far I was not able to find how to send data in a way that the system interprets the optional parameters correctly. 

Lets take the following example : 

var URL = '[code]<a href="' + gs.getProperty('glide.servlet.uri') + '/'+ "incident" + '.do?sys_id=' + "e6f453a7c360da148c5cb0d4e4013136?" + '" target="_blank">' + 'My Record test 8' + '</a>[/code]


This works well, and clicking the link opens the record in a sub tab by default. Now ideally I want to add some optional parameters to this url. If we look at Workspace URL routing - Support and Troubleshooting (servicenow.com) it mentions that params should be serialized to the form :

"params/name1/value1/name2/value2 etc. So {params: {foo: '123', bar: 'abc'}} becomes /params/123/bar/abc"

But this does not seem to work when using the hyperlink, everything added after the sys_id is not being taken as a parameter but instead as a continuation of the sys_id , resulting in something like : 

https://abc/record/incident/e6f453a7c360da148c5cb0d4e4013136/params/selected-tab-index/0/sub/record/incident_task/e6f453a7c360da148c5cb0d4e4013136%2Fparams%2F123%2Fbar%3Dabc


DiogoRamos_1-1727700524783.png
So if anyone has any idea if this is achievable let me know. (btw I know I make create the entire URL and that would work but it would always open a new browser tab.

1 ACCEPTED SOLUTION

Diogo Ramos
Giga Sage

Ended up moving away from having the url in the work notes as it was indeed hard to manage the custom parameters, and created a new string field which I update with a JSON object, and it gets updated throughout the lifecycle of the record. With the data of this field, I display a new sidebar tab where for each record I display a card that will contain the data I need based on that JSON content: 

DiogoRamos_0-1727945834226.png
I then have multiple cards, where the user can click to open a side by side view of 2 given records(here is where I pass custom parameters for each card depending on the data that needs to be fed to the comparison view (using the comparator component) in another record page. 

Cheers
Diogo


 

View solution in original post

4 REPLIES 4

-O-
Kilo Patron
Kilo Patron

I would say what you are doing is moving a lot of data - that should be represented in references and related list - into a work notes.

If an incident is often linked to such records, present a related list or reference where the incident can be linked.

Then you can use a side-tab where - based on the reference - you can do crazy stuff, presenting all sorts of links and whatnot.

There are OOB plugins like task relationships where you can relate tasks the same as you would relate CIs using cmdb_rel_ci.

Although I understand your point, the question is really about the possibility of passing parameters within a clickable url, with the goal of opening the same record with different optional parameters, maybe the example I used was not the greatest and indeed to show incident tasks it would make sense to use a related list.

 

Either way the approach I will use is to move this type of data to a json field and then in ui builder build the links based on that data, and there I can use the redirection events with the parameters I want.

 

Thanks for the answer.

You're most welcome 🙂

Diogo Ramos
Giga Sage

Ended up moving away from having the url in the work notes as it was indeed hard to manage the custom parameters, and created a new string field which I update with a JSON object, and it gets updated throughout the lifecycle of the record. With the data of this field, I display a new sidebar tab where for each record I display a card that will contain the data I need based on that JSON content: 

DiogoRamos_0-1727945834226.png
I then have multiple cards, where the user can click to open a side by side view of 2 given records(here is where I pass custom parameters for each card depending on the data that needs to be fed to the comparison view (using the comparator component) in another record page. 

Cheers
Diogo