Javascript (value of type)

From JRapid

Jump to: navigation, search

JavaScript actions allow developers to associate an action to a specified JavaScript function.


To write JRapid JavaScript actions you should specify that the action is of type action "javascript", then you would be able to specfiy the function attribute which is the name of your javascript function.


  • Calling a javascript function from an entity:

In this example we find ourselves in the need of calling a JavaScript function from a given form or list. This might be the case when I want to take a specific action related to an entity or list of entity's instances. For example, I have a list of employees, and I want to be able to select one or more of them and indicate that their yearly review is schedule for the next days. By doing this an e-mail will be sent to the company reviewers with the information of the employees chosen.

<entity name="Employee" label="Employee">
     <property name="name" label="Name" display="primary" unique="unique"/>
     <action label="Schedule Review" type="javascript" function="scheduleReview"

Therefore our javascript function will be:

 function scheduleReview(obj, ids) {
  • Calling a javascript function from a property:

In this other example, a function is called from a given property, in order to do something with its information.

<entity name="person" label="Person">
     <property name="name" label="Name" display="primary" unique="unique">
         <action label="Look for related" type="javascript" function="lookForRelated"/>

Therefore our javascript function will be:

 function lookForRelated(obj) {

See also:

Personal tools