Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Module Link Type - Script (From Arguments) Not Working

chaslage
Kilo Guru

I am looking to create complete unique overview pages based on the person's assignment group, I got the idea from this post: Adding external link to Module

However, I am having an issue that when I add any script to the module I create it gives an error. Not sure what is going on, so I attached a picture in hopes someone knows the answer.

Right now I am just using javascript:window.open("http://www.google.com"); as the code in the Arguments area and it still errors out.

Thanks!

4 REPLIES 4

chaslage
Kilo Guru

People were using URL and not Script. I needed something a bit more specific, so I created a script:


var usr = gs.getUserID();
var aUser = new GlideRecord('sys_user');
var overviewPage = '';
aUser.addQuery('sys_id', usr);
aUser.query();
if (aUser.next()) {
overviewPage = '?sysparm_view='+aUser.u_default_assignment_group.u_overview_page;
}

var redirectURL = '/home.do'+overviewPage;

gs.print('<a href="'+redirectURL+'">Click here if you are not automatically redirected...</a>'+
'<script>document.location.href = "'+redirectURL+'"</script>');


This will automatically redirect users to their custom Overview page based on their Default Assignment Group.


Hi Chris,



The above post was very helpful in building certain functionality which I needed for a custom application. It worked very succesfully in our Prod instance (Calgary). We've just upgraded our Dev environment to Eureka and the functionality no longer works. It now just prints the gs.print line, rather than actually redirecting.



Have you upgrade to Eureka as of yet? If so did you have the same issues?



Thanks


- Scott


Don't know it is working in previous versions of SNOW or not but it is not working in Eureka patch9



Below is the simple code I have written but it is not working



a.png


Syvo
Giga Guru

In case someone is looking for a solution for this in newer versions, there are at least two :


  • create a "HTML (from arguments)" module that builds the link with a client <script> (no gs)
  • closer to Christopher's redirect solution, create a custom UI Page that builds the query in Jelly and redirects the client to this URL; change the module itself so that it points to this UI Page with type : URL (from arguments)


HTH