viernes, 1 de julio de 2016

[JD Edwards] Insert Javascript Code in Applications

In one of the latest projects, one of the requirements could easily be solved with JavaScript. But there was never inserted JavaScript code in an application of JD Edwards (I have not had this need).

I knew that it's possible insert HTML code in text blocks, but if you can add HTML code then you could embebed JavaScript!!

So, I was investigating and working in it, and I got add JavaScript in my JDE application!!!

Alert JavaScript from JD Edwards

In some post I read about for 8.90 and later versions you must enable security for it, but in my case I need with JD Edwards 9.2.

Code Example:

     evt_HTML_A030
     evt_iSegmentID_INT01
     evt_Message_ALPH
     evt_WebcenterContentLogin_URL
     OPT: Using Defaults
0001 //
0002 // Initialize Variables
0003 //
0004 VA evt_HTML_A030 = ""
0005 VA evt_iSegmentID_INT01 = 1
0006 //
0007 // Notify the tool that the Information text block contains encoded text.
0008 //
0009 Encode(FC Text Block 100, VA evt_HTML_A030, VA evt_HTML_A030)
0010 //
0011 // HTML & Javascript Code
0012 //
0013 //  
0014 VA evt_Message_ALPH = ""Hello JavaScript!!!""
0015 VA evt_HTML_A030 = concat([VA evt_HTML_A030],"<script type="text/javascript">")
0016 VA evt_HTML_A030 = concat([VA evt_HTML_A030],"function abrirVentana(){")
0017 VA evt_HTML_A030 = concat([VA evt_HTML_A030],"alert(")
0018 VA evt_HTML_A030 = concat([VA evt_HTML_A030],concat([VA evt_Message_ALPH],");"))
0019 VA evt_HTML_A030 = concat([VA evt_HTML_A030],"}")
0020 VA evt_HTML_A030 = concat([VA evt_HTML_A030],"</script>")
0021 VA evt_HTML_A030 = concat([VA evt_HTML_A030],"<button onclick="abrirVentana();">")
0022 VA evt_HTML_A030 = concat([VA evt_HTML_A030],"Alert</button>")
0023 VA evt_HTML_A030 = concat([VA evt_HTML_A030],"<script>")
0024 //
0025 // Add HTML & JS to segment
0026 //
0027 Add Segment(FC Text Block 100, VA evt_HTML_A030, <Default,Default,0,Default>, <No>, VA evt_iSegmentID_INT01)

The next steps will be create my own JavaScript library for separate and organize my JS code, and it allow will be more easier and faster to access JS functions.

Personally, I thint it opens up world of possibilities.

Welcome to Custom JD Edwards Applications, Javascript.

7 comentarios:

  1. Is it possible to invoke javascript from jde event. I mean without the button in text block.

    ResponderEliminar
    Respuestas
    1. Of course Imran, you can declarate the function and then call it. regards.

      Eliminar
  2. Hi there,

    I tried your code as indicated but it is doing nothing as if it is blocked or secured...Any ideas?

    ResponderEliminar
    Respuestas
    1. Hi Unknown,
      Review the code with inspect in your browser for check is all ok. But if is ok, try lowering explorer security.
      Regards.

      Eliminar