TO DO

This section is incomplete and will be concluded as soon as possible.
 

1 Catalogued SQL

 

2 Javascript functions

 

3 Globals

 

4 Form events

Allows to execute logic by form level.


Event type Execut JS when...
Before Input Click on the button which has reset form function.
Before Insert Click on insert register button before executing INSERT sentence.
Before Update Click on modify button register before executing UPDATE sentence.
Before Delete Click on delete button register before executing DELETE sentence.
On Load Browser loads the form.
On Unload Focus leaves the page (which contains the form).
 

5 Field events

Allows to execute logic to level all fields of the forms.

It is needed to indicate the field where JS has been executed when the event has done.

Event type Executes JS when...
Reset Click button used to reset the form.
On Focus Focus enters on the field.
On Blur Focus leaves the field.
On Change Focus leaves the field and value is modified.
On Click Click on field.
 

6 Actions

Form Actions can be triggered from Client Side calling the JS function executeFormAction(action_code).

Copy
executeFormAction("ACTION_REFRESH_CURSOR");

As the action is not called from a server object, some functionalities will not work when calling a form action with a JS function, like these:

  • Icon and Style of the action have no sense when calling form action from Client Side
  • Update mode will not work if it is "Refresh Box", in this case the "Refresh row" mode will be applied

Also, form actions will not work in these situations:

  • When an action is called from Client Side, the data will come from the closest sql statement:
    • If the statement match with the adapter the call will be executed correctly
    • Otherwise, if the action has references to data the call will not work because it is not known which is the closest statement
  • When an action has an Iteration statement defined, it will not execute correctly

Action constraint

Like on Server Side, only actions of the current JRep Object can be executed.
 

7 Pre-defined functions

More info  

8 Import of Javascript code

 

8.1 Main box

Menu path:
Objects / Definition / Form definition / Javascript
wic_jrep_form_import_js
Label Description
Code Code
Description File description
Content Javascript code

Size File size
Rows Number of rows in the code
CRC CRC checksum number

  • Default: dcrc-32(js_data)
User created User created
Date created Creation date

  • Default: CURRENT
User updated User updated
Date updated Last update date
Actions
Button Title Notes
BUT_GENERAR_DELTA Generate delta null
 

8.2 Example

The following example shows how to automatically inform the email field of the employee form by entering the first and last name. To do this, a Javascript function will be defined that will be cataloged and assigned to the employees object.

To start, you have to define the javascript function that you want to import. In this case, it would be as follows:

  • Code: emailfromname

  • Description: Email from name

Definition of the function:

Copy
function emailfromname(firstname, lastname, database) {
    return firstname + '.' + lastname + '@' + database + '.com';
}

Once the javascript function that you want to import has been defined and selected, you must go to the section 'Events' where the sentence that will be executed by the javascript will be defined, in this case, each time the focus of the javascript is removed. the column 'firstname'.

For this, in 'Colname' you have to put 'firstname' and the definition of the event will be as follows:

Copy
var m_email = emailfromname(getFieldValue("employee.firstname"),
              getFieldValue("employee.lastname"),getDbms());
var m_curr_email = getFieldValue("employee.email");
if(m_curr_email===''){
   setFieldValue("employee.email",m_email);
}

Now in the form 'employee' if the user wants to insert a new employee.


By filling in the sections 'name' and 'last name', you will automatically receive an email, also using the database in which the form is located.



In the same way, the JavaScript function will be imported into the form 'client'.


In this case, in the event it will be indicated that the function is executed when the focus of the column 'surname' is removed and the sentence will be as follows:

Copy
var m_email = emailfromname(getFieldValue("customer.firstname"),
              getFieldValue("customer.lastname"),getDbms());
var m_curr_email = getFieldValue("customer.email");
if(m_curr_email===''){
   setFieldValue("customer.email",m_email);
}

Now, as in the employee form, when the 'name' and 'surname' fields are filled in, the field 'email' will automatically be informed.


The import of JavaScript code into forms is done starting from the premise that the code will be assigned to more than one form. Cataloging a Javascript for a single form is meaningless, since it can be included directly in the form itself.