RunJavaScript Action Script.

Hi All,

I am trying to run a script using RunJava Script action, to integrate a tool.

 But not able to format this script in outsystem format,  Any idea how can i run this script using RunJavaScript action, i did some workaround and changed the " to ' but still not getting any result.



Thanks 

Rajendra singh

Hi,

You need to have " in the beginning and in the end because that action accepts text. in the script code I prefer to use ' but if you need to use " you need to use "" to Outsystems understand it is a quote and not the end of the text.

Check this document for some example.

Regards,

Marcelo

Marcelo Ferreira wrote:

Hi,

You need to have " in the beginning and in the end because that action accepts text. in the script code I prefer to use ' but if you need to use " you need to use "" to Outsystems understand it is a quote and not the end of the text.

Check this document for some example.

Regards,

Marcelo

Thanks Marcelo,

But i have already replaced the " with ' and its  not working as expected.

"<script type='text/javascript'>/*{literal}<![CDATA[*/window.lightningjs||function(c){function g(b,d){d&&(d+=(/\?/.test(d)?'&':'?')+'lv=1');c[b]||function(){var i=window,h=document,j=b,g=h.location.protocol,l='load',k=0;(function(){function b(){a.P(l);a.w=1;c[j]('_load')}c[j]=function(){function m(){m.id=e;return c[j].apply(m,arguments)}var b,e=++k;b=this&&this!=i?this.id||0:0;(a.s=a.s||[]).push([e,b,arguments]);m.then=function(b,c,h){var d=a.fh[e]=a.fh[e]||[],j=a.eh[e]=a.eh[e]||[],f=a.ph[e]=a.ph[e]||[];b&&d.push(b);c&&j.push(c);h&&f.push(h);return m};return m};var a=c[j]._={};a.fh={};a.eh={};a.ph={};a.l=d?d.replace(/^\/\//,(g=='https:'?g:'http:')+'//'):d;a.p={0:+new Date};a.P=function(b){a.p[b]=new Date-a.p[0]};a.w&&b();i.addEventListener?i.addEventListener(l,b,!1):i.attachEvent('on'+l,b);var q=function(){function b(){return['<head></head><',c,' onload='var d=',n,';d.getElementsByTagName('head')[0].',d,'(d.',g,'('script')).',i,'='',a.l,''\'></',c,'>'].join('')}var c='body',e=h[c];if(!e)return setTimeout(q,100);a.P(1);var d='appendChild',g='createElement',i='src',k=h[g]('div'),l=k[d](h[g]('div')),f=h[g]('iframe'),n='document',p;k.style.display='none';e.insertBefore(k,e.firstChild).id=o+'-'+j;f.frameBorder='0';f.id=o+'-frame-'+j;/MSIE[ ]+6/.test(navigator.userAgent)&&(f[i]='javascript:false');f.allowTransparency='true';l[d](f);try{f.contentWindow[n].open()}catch(s){a.domain=h.domain,p='javascript:var d='+n+'.open();d.domain=''+h.domain+'';',f[i]=p+'void(0);'}try{var r=f.contentWindow[n];r.write(b());r.close()}catch(t){f[i]=p+'d.write(''+b().replace(/'/g,String.fromCharCode(92)+''')+'');d.close();'}a.P(2)};a.l&&setTimeout(q,0)})()}();c[b].lv='1';return c[b]}var o='lightningjs',k=window[o]=g(o);k.require=g;k.modules=c}({});
window.xyz_live = lightningjs.require('xyz_live', '//w.xyz.com/xyz.js');
/*]]>{/literal}*/</script>
"

Can you please write "" in text(comma double quotation mark), cant read properly.



 


Hi Rajendra,

This looks like minified javascript. Instead of including it as an expression, why not include it as a .JS file inside a resource? That way you wouldn't have to to bother with replacing characters.

Check this thread for a good overview of the process.

Afonso Carvalho wrote:

Hi Rajendra,

This looks like minified javascript. Instead of including it as an expression, why not include it as a .JS file inside a resource? That way you wouldn't have to to bother with replacing characters.

Check this thread for a good overview of the process.


Hi Afonso,

Thanks.

Is anything wrong with this script, Can i run this script using Runjava Script action? 

There's nothing wrong with the script itself, but since it is minified code, it looks like it belongs inside a javascript resource file. The advantage of doing this is that the browser can cache this code (it won't if it's inside an expression) and it's going to be easier to maintain (you don't need to try and read minified javascript inside an expression, and you don't have to spend your time replacing double quotes).

Hi,

I usually replace all double quotes with single quotes, it works just fine. So it would be much readable. Then enclose everything with double quotes.