URL (from Arguments) script include not working

rajashekar
Kilo Contributor

Hi I am not able call script include from module link type - URL (from arguments)

when I do a JavaScript call in module nothing happens

javascript: new script include name().function name();

I want to redirect user to different portal pages based on users country

 

script include return the correct URL based on the users country

Regards,

Rajashekar

 

 

 

1 ACCEPTED SOLUTION

Anil Lande
Kilo Patron

Hi,

It is not possible to call script include in argument field of Modules. That field just store the argument.

 

But to achieve similar requirement we have implemented redirection as given below:

1. create a UI Page 'sp_redirect.do'

find_real_file.png 

2. Create a UI macro 'sp_redirect_macro' which is referred in UI Page

find_real_file.png

 

3. And update your module like with UI Page name.

 

find_real_file.png

 

 

Below is the UI macro script for your reference:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_country" object="true">
   var userGr=new GlideRecord('sys_user');
   userGr.get(gs.getUserID());
   var countrycode = userGr.getDisplayValue('country');
   countrycode;
</g:evaluate>	
<g:evaluate var="jvar_portal" object="true" >
   var instUrl = gs.getProperty('glide.servlet.uri');
   instUrl;
</g:evaluate>
<script >
	var sp;       
	var userCountry = "${jvar_country}";
	 var url = "${jvar_portal}";
	 if(userCountry== 'Brazil'){  //for brazil use different portal
	 sp = 'spbr';
	 }else{
	 sp = 'sp';
	 }	 
	 window.location = url + sp;	 
</script>	
</j:jelly>

 

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

8 REPLIES 8

@Anil Lande I have a question about the UI Macro Jelly code.  I'm not experienced with Jelly or its tags so I don't yet know the answer to this:  Does the code within the UI macro's <g:evaluate> tags get executed on the server or client?

I ask because there is the obvious GlideRecord query in that part of the code and I know that normally, within the platform client scripts at least, best practice is to not invoke GlideRecord queries from the client. (ie, instead we are to use AJAX w/ server-side script include, etc.)

But as I said, I am not experienced with Jelly so I do not exactly know how everything is getting processed within this solution.

Thanks for any additional insight you can provide.

Hi,

<g:evaluate> tag execute at server side, you can make script include call to evaluate value of jelly varibales.

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Maik Skoddow
Tera Patron
Tera Patron

Hi,

you can use link type "Script (from Arguments)". At field "Arguments" you can insert your JavaScript code without the prefix "javascript:"

Kind regards

Maik

Upender Kumar
Mega Sage

Try below

Create script include and make it client callable. I tried without it but it is not working.

find_real_file.png

 

find_real_file.png