Adding external link to Module

dhananjay_m
Kilo Contributor

I have case where in the Module on left hand navigation needs to be pointing to external links(out of Service now) which will be dynamic based on different environments such as dev, uat ,prod. So in case of dev the module link should point to http://www.xyz.com in case of uat it should point to http://www.abc.com and similarly for prod. I tried with URL (from arguments) but this typically doesn't solve my problem as I cannot associate a javascript function call in it. Script (from argument) also doesn't work in this case as it renders a script as a script call instead of evaluating the function. Ideal scenario would be if I can associate a function within the arguments where I can decide which link to render based on current service now instance.

Any one has come across such scenario?

Thanks,
Dhananjay

10 REPLIES 10

dhananjay_m
Kilo Contributor

This may not help in my case because even in that case I will need to setup links in my Service now instance to point it to a a common link in my receiving application which will be pointing to different links for DEV, QA or PROD

So the module link will be URL(from argument) frin each service now instance. But my end point point application could be running different instances for DEV, QA or PROD.


dhananjay_m
Kilo Contributor

This piece works: javascript:window.open("http://www.google.com/");

But what I am really looking for is that I can call a script function by passing some params which will decide what the link to open. And there are about 30 such links so I can't be doing these changes for each of my Service now environments. All the links would be pointing to different component/iframes which would be external to Service now.

So something like for Link 1 if we set Link type as URL ( from arguments) I need to be able to attach a script like
javascript:fncGenerateURL('xxx');

This function will give me back a URL such as xyz.com/guid=xxx which will differ in each Service now environment.

So for Dev
Link 1 - xyz.com/guid=xxx
Link 2 - xyz.com/guid=yyy
Link 3 - xyz.com/guid=zzz

For QA
Link 1 - abc.com/guid=xxx
Link 2 - abccom/guid=yyy
Link 3 - abc.com/guid=zzz

For Prod
Link 1 - pqr.com/guid=xxx
Link 2 - pqr.ccom/guid=yyy
Link 3 - pqr.com/guid=zzz

Alternate option could be to change the Jelly script which actually renders these links so that I can attach my functionality on click. But what I really don't know is where this script is written.

Thanks,
Dhananjay


You could use custom system properties which can be populated from anywhere you like (e.g. a business rule). Say then you have created a property called custom.myproperylink1 and a BR has assigned it a value. Then you could use "fixes string/"+gs.getProperty('custom.myproperylink1') as a parameter to open the link. Would that help?


dhananjay_m
Kilo Contributor

Well your idea got me excited for a moment and thought of first checking if I can actually evaluate gs.getProperty('xyz') in the arguments section of a module. But unfortunately the text just get appended to the Service now instance url instead of returning a value.

So I did this

1. Created a "TestLink" module with Link type as URL(from arguments).
2. setting argument field
javascript:window.open(gs.getProperty('custom.myproperylink1')); - DIDN'T WORK 😞 The property didn't evaluate.
Although this works javascript:window.open('http://google.com'); and it opened a google window

May be there is a different way to refer the Service now objects such as gs or a script include function within Argument field of a module ?


Found a small break through !! I can access a custom property by using a jelly script tag

javascript:window.open('${gs.getProperty(''custom.myproperylink1')}');

Next step would be if I can make a call to a Script include function using something similar