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

Saurabh Gupta
Kilo Patron
Kilo Patron

Please try to print the URL in background script.

javascript: new script include name().function name(); and share the screenshot?


Thanks and Regards,

Saurabh Gupta

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

Hi Anil Lande,

Thankyou for the reply,

I have tried many ways, nothing was working
but what you had suggested works perfectly.

I am only facing one issue in the UI macro script my code is not going inside the if condition

it is by default taking the else condition

only change I have done is in place of country I have used domain condition

 

Hi Anil Lande,

Thankyou for your reply,

This works perfectly as expected and thankyou for your time you have taken write all the code.

 

Regards,

Rajashekar