About Me

My photo
Dhaka, Dhaka, Bangladesh
✔4x Salesforce Certified ✔Web Application Developer ✔Database Developer with DWH/ETL/BI • Successful solution engineer and developer with 16+ years of experience multiple technology and in different countries. Proficient in implementing business requirements into the technical solution. Experience handling all phases of the project lifecycle from discovery through to deployment. Worked as technical lead for a team of junior developers to make sure code stayed in line with requirements and standard best practices. Skilled at integrating disparate systems with Salesforce.Experience implementing Salesforce Community Cloud at two previous companies.

Thursday, April 21, 2011

Forms 11g new features: Javascript-API / WHEN-CUSTOM-JAVASCRIPT-EVENT

Forms 11g allows the direct communication between the generic java-applet in the browser and the world around. The new JavaScript-API implements this functionality.

In Forms 11g we have a new trigger, system-variables and built-ins for the communication with the JavaScript-API.

The trigger WHEN-CUSTOM-JAVASCRIPT-EVENT fires each time, when JavaScript raises an event to forms. In the trigger we can use the payload which is stored in two system-variables. system.javascript_event_name and :system.javascript_event_value.


Informations, which were transfered from HTML to Forms, can be easily used:


In this little example we transfer in the payload the event-name "NewForm" and in the event-value the name of a form. The data is transfered from the internet-page in this way::
< INPUT id="outside_field_id">
< SCRIPT>
  function set_field (field_id, myValue) {
    document.getElementById(field_id).value=myValue;
  };
  function clickEvent1()
  {
    document.forms_applet.raiseEvent("NewForm", "payload");
  }
< /SCRIPT>
< INPUT id="button1" type="button" onClick="void clickEvent1();" value="NewForm">

Internally the method raiseEvent of the class forms_applet is used. The applet's name has to be assigned in the formsweb.cfg to the parameter applet_name.
applet_name=forms_applet

Forms can communicate bi-directional with the HTML. Therefore we can use the new built-ins web.javascript_eval_expr and web.javascript_eval_function.
web.javascript_eval_expr
    ('document.getElementById("outside_field_id").value="' ||
     :control.ti_inside || '";');
  web.javascript_eval_expr 
    ('set_field("outside_field_id", "' || :control.ti_inside
     || '")');
  :control.ti_get_value := web.javascript_eval_function
    ('document.etElementById("outside_field_id").value');

This example-code fills in the HTML-page a field named "outside_field_id" through the built-in web.javascript_eval_expr. Two techniques can be used. Direct Assignment or the call of a javascript-function, e.g. „set_field“.
You can read field through web.javascript_eval_function. The returnvalue is the value of the corresponding field in the HTML, in this case "outside_field_id".

This is another example of how important the new features in Forms 11g are. Now it's possible for forms to communicate with the world outside the browser's applet!

No comments:

Post a Comment