Communicating Between an HTML Field and a Mid-Tier Form

Version 4
    Share This:

    An operation can be easily performed on a non-AR System® (HTML) field from a Mid-Tier form and vice versa using "Events". The HTML content resides in a View Field, which is an iframe in the containing form. This article assumes that the reader has a basic knowledge of JavaScript in browsers and is familiar with AR System 6.3 and will describe how to communicate between an HTML field and a Mid-Tier form.

    Communicate By Sending Data from a Parent Form to a View Field

    Step 1: Introduce a broker java script object in the parent form.
    (Through the parent java script object in the View Field)
    Step 2: Use the JAVASCRIPT "run process" action to send data to the broker.
    Step 3: The broker forwards data to the contents of the View Field.

    Following is an example of how to achieve this communication.

    1. Create an application called ViewTest and add this html to the resource (Application property->support files tab).
    2. Create a form called View in that application and add a View Field and set the text to point to the HelloWorld html file. Example, http://<MidTier>/arsys/apps/<ARServer>/ViewTest/resources/HelloWorld.html
    3. Add a character field (Data) and a button (SendEventToView) to the form.
    4. Create an active link (Send Event to View) acting on the View form, action on button click (SendEventToView). Add a RunProcess action and copy the following in the command line. Note: $Data$ is the character field we created in the View form.
      JAVASCRIPT MyBroker.SendEventToField("$Data$");
    5. Open the form on the Web and click the SendEventToView button after setting some value in the data field.

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <script>
        function ol() {
          if (parent) {
            parent.window.MyBroker=new function() {
              var curwin=window; 
           var par=parent;
              this.SendEventToForm=function(eventtype) {
                par.ARProcessEvent.Add(eventtype, 'ID001'); };
              this.SendEventToField=function(eventtype) {
                curwin.handleEvent(eventtype);
              };
            };
          }
        }
        function handleEvent(eventtype) {
          var textEle=document.getElementById('textid');
          textEle.value=eventtype;
        }
        function sendEvent() {
          var textEle=document.getElementById('textid');
          var et = textEle.value;
          parent.window.MyBroker.SendEventToForm(et);
        }
        </script>
      </head>
      
      <body onload=ol();>
        <h1>Hello World</h1>
        
        <input id=textid type=text value=foo />
        <input type=button value=SendEvent onclick=sendEvent(); />
      </body>
    </html>

    Communicate by Sending Data from the View Field to the Parent Form

    Step 1: View Field content sends data to the broker
    Step 2: Broker sets data in the parent form through either of the following two ways:

    • Send event to the parent form
      (Caveat – The method used here is version specific).
    • Set specific fields
      (Caveat – The method used here is version specific) e.g. F(fieldID).S(new CharType("Hello"));
      Here the fieldID is the field to be set on the parent form, S is the Set method call and the parameter value to this function should be of some data type such as CharType, DateType, RealType etc. The data type names are not documented since it is not officially supported. If you are knowledgeable in JavaScript, please refer to the clientcore.js file for information on various data types.

    Step 3: Broker forwards data to the View Field contents.

    Following is an example of how to achieve this communication.

    1. Follow the first 3 steps of above example (sending data from parent to view example)
    2. Create an active link called Handle Event and select the Event as the Execute On condition.
    3. Add a Set Fields action and set the Data field to $EVENTTYPE$.
    4. Click the SendEvent button inside the ViewField after typing some value in the field. See the snapshot below for more information.

    Note: Click images for full screen view.

    Figure 1 – Send Event Button Functionality

    Summary

    Now you should be able to get started communicating between an HTML field and a Mid-Tier form.

    ~ Nirmala
    Staff Product Developer, Remedy Core Development
    Joined BMC Remedy in 2000

    Related Topics:

    • AR System 6.3 Basic Workflow Administrator's Guide - Workflow Extras:  Sending Events Between Windows (Supportweb - login required)