Script Editor Tool

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

Table of Contents{{#if: Functionality| | Functionality }}{{#if: | | [[{{{3}}}]] }}{{#if: | | [[{{{4}}}]] }}{{#if: | | [[{{{5}}}]] }} | Script Editor Tool{{#if: Shipment Info| | Shipment Info }} ⇒


The Script Editor Tool provides a way to test simple scripts while the application is running.

Access

Icon: Icon Script24.png
Menu: →Script }}{{#if: | → }}{{#if: | → }}
Short Cut: none

Restrictions

To access the Script Editor Tool, your must be logged in as an administrator.

The tool is very simple in function.

Only Beanshell & Groovy scripts are supported.

Description

When logged in as a user with Administrator rights, you can access the Script Editor Tool through the menu as described above or also by a pop-up menu (right click of the mouse) when you are in a Memo Field or Text Field of a column named "Script". See the {{#if: |{{{2}}}|Rule }} Window.

The Script Editor Tool opens with a screen similar to the one below.

 

ScriptEditorTool.png

At the bottom of the screen are buttons to validate (Icon Customize24.png), execute (Icon Process24.png), cancel or confirm and a text box which shows the value of the "result" variable converted to a string. If the script was opened from a Memo field, clicking the confirm button will save the changes in the field, otherwise, all changes will be lost.

Note.gif Note:

It bears repeating. If you open the script from the menu, any changes you make will be LOST when you confirm or exit the tool. There is no provision to save scripts to a file. To save the script you have to be using the tool from a Memo field with the name Script. Otherwise, remember to copy the script text to the clipboard before you close the editor and paste the clipboard somewhere safe.

In developing the script the context variables below can be accessed directly. You can also use the Env class to access the system context. For example:

import org.compiere.util.Env;
result = Env.getContextAsInt(Env.getCtx(), "#AD_User_ID");

is the same as

result = G_AD_User_ID;

From a callout, you can use the context variables passed in to access other elements of the context in the following manner.

import org.compiere.util.Env;
result = Env.getContext(A_Ctx, A_WindowNo, "WindowName");


Context Variables

Window context variables start with a W_ prefix. (Note that these to do appear to work while editing the script.)

Login context variables start with G_ prefix.

Event Variables

Note.gif Note:

Event variables are only available to the script during the event process. You won't be able to test them with the editor.

Callout:

  • A_WindowNo
  • A_Tab
  • A_Field
  • A_Value
  • A_OldValue
  • A_Ctx

Process:

  • Process Parameters for the process start with P_ prefix, for example P_Name. If the parameter is a range then the parameters will be P_Name1 and P_Name2
  • A_Ctx - the context
  • A_Trx - the transaction
  • A_TrxName
  • A_Record_ID
  • A_AD_Client_ID
  • A_AD_User_ID
  • A_AD_PInstance_ID
  • A_Table_ID

Login validator:

  • A_Ctx
  • A_AD_Client_ID
  • A_AD_Org_ID
  • A_AD_Role_ID
  • A_AD_User_ID

Table and document model validator:

  • A_Ctx
  • A_PO
  • A_Type
  • A_Event

See Also

For Developers

The software that displays this window can be found in:

  • client/src
    • org.compiere.apps.BeanShellEditor.java
    • org.compiere.apps.GroovyEditor.java
    • org.compiere.apps.ScriptEditor.java
    • org.compiere.grid.ed.VMemo.java