View source | Discuss this page | Page history | Printable version   
Main Page
Upload file
What links here
Recent changes

PDF Books
Add page
Show collection (0 pages)
Collections help


How to create a Pick and Execute Process



Pick and Execute (P&E) is a case of Process Definition with Standard UI pattern.

This how to will add a new Pick and Execute process and associate it with the Sales Order window.

The implementation requires development experience. See the following concept pages for background information on action handlers and javascript development:

It also makes sense to study the following page: Openbravo_3_Architecture.

Bulbgraph.png   The Pick and Execute processes explained in this how to, is available from 3.0MP6

Example Module

This howto is supported by an example module which shows examples of the code shown and discussed.

The code of the example module can be downloaded from this mercurial repository:

The example module is available through the Central Repository (See 'Client Application Examples'), for more information see the Examples Client Application project page.

Steps to implement the Process


The P&E processes take advantage of the same foundation concepts in the Application Dictionary. We'll be using the Window, Tabs and Fields for defining the editable grid that will be shown, a new Reference for the parameter of the process; and then implementing an action handler that will get executed when the user hits the "Done" button.


Defining the Window


Defining the Reference

After defining the window, you need to define a new Reference.


Defining the Process

There is a new window for processes: Process Definition

Bulbgraph.png   Window Reference is the an implementation of a rich parameter

Adding a button to Sales Order

Create a Column

As you know, you required to have a new column to associated it to a button.

Bulbgraph.png   You can check other how-to if you are not confident with this process, e.g. How_to_add_a_field_to_a_Window_Tab
ALTER TABLE c_order ADD COLUMN em_obexapp_pick1 character(1);
ALTER TABLE c_order ALTER COLUMN em_obexapp_pick1 SET DEFAULT 'N'::bpchar;
Create a Field

Java Implementation

As mentioned earlier you should be confident with the concept of an action handler.

In the case of a Pick and Execute action handler, you must extend from BaseProcessActionHandler and implement the doExecute method.

 * The contents of this file are subject to the Openbravo  Public  License
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
 * Version 1.1  with a permitted attribution clause; you may not  use this
 * file except in compliance with the License. You  may  obtain  a copy of
 * the License at
 * Software distributed under the License  is  distributed  on  an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific  language  governing  rights  and  limitations
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
 * All portions are Copyright (C) 2011 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
package org.openbravo.client.application.examples;
import java.util.Map;
import org.apache.log4j.Logger;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;
import org.openbravo.client.application.ApplicationConstants;
import org.openbravo.client.application.process.BaseProcessActionHandler;
 * @author iperdomo
public class PickExampleActionHandler extends BaseProcessActionHandler {
  private static final Logger log = Logger.getLogger(PickExampleActionHandler.class);
  protected JSONObject doExecute(Map<String, Object> parameters, String content) {
    try {
      JSONObject request = new JSONObject(content);">> parameters: " + parameters);
      //">> content:" + content);
      // _selection contains the rows that the user selected.
      JSONArray selection = new JSONArray(
          request.getString(ApplicationConstants.SELECTION_PROPERTY));">> selected: " + selection);
      // _allRows contains all the rows available in the grid
      JSONArray allRows = new JSONArray(request.getString(ApplicationConstants.ALL_ROWS_PARAM));">> allRows: " + allRows);
      // A Pick and Execute process can have several buttons (buttonList)
      // You can know which button was clicked getting the value of _buttonValue">> clicked button: " + request.getString(ApplicationConstants.BUTTON_VALUE));
      return request;
    } catch (Exception e) {
      log.error("Error processing request: " + e.getMessage(), e);
    return new JSONObject();

Testing the Process

Since you have changed the structure of some Entity by adding a new column, you need to restart the tomcat server.


Advanced Topics

Selecting by default

Your data-source (table or view) defined in the Tab, can set which rows will be selected by default when the user launches the process. You just need to create a column c_ob_selected, this will turn into a obSelected property in the generated entity. When the value of this column is 'Y', the row will be selected by default. Here you have an working example: M_RM_RECEIPT_PICK_EDIT.xml.

Note that when registering the column in the Application Dictionary the Yes/No reference must be used.

Validation Function

You can define at Field level a JavaScript validation function. In an editable field when the user enters a value, this function will get executed.


JavaScript Definition

OB.OBEXAPP.PNE.validate = function (item, validator, value, record) {
  // item has access to grid: item.grid
  // from the grid you can get all selected records and edited values, e.g.
  //   * item.grid.getSelection()
  //   * item.grid.getEditedRecord()
  // grid has access to view: grid.view
  // view has access to parentWindow: view.parentWindow (the window running the process)
  // parentWindow has access to currentView
  // currentView has getContextInfo
  // debugger;
  if(window.console) {
    console.log('validation function!', value);
  return true;

Selection Function

You could also define a selection function, at Tab level. This function will get called when the user select/unselect a row.


And define a JavaScript function in your loaded static .js file:

OB.OBEXAPP.PNE.selectionChanged = function (grid, record, recordList) {
  if (window.console) {
    console.log('selection function!');
    console.log(grid, record, recordList);

If you want to change any value of the selected record, you have to use the following instruction:

grid.setEditValue(grid.getRecordIndex(record), columnName, newColumnValue)

Performing Several Actions after Execution

After the process is executed, a series of actions can be taken. How to do it is explained here.

Retrieved from ""

This page has been accessed 20,565 times. This page was last modified on 27 June 2018, at 06:14. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.