Difference between revisions of "Script Callout"

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.
m
(prefixes)
Line 7: Line 7:
  
 
Within the script you can use:
 
Within the script you can use:
* Window context variables start with a single dollar sign $
+
* Window context variables start with a W_ prefix
* Login context variables start with two dollar signs $$
+
* Login context variables start with G_ prefix
* Parameters for callout start with three dollar signs $$$
+
* Parameters for callout start with A_ prefix
** $$$WindowNo
+
** A_WindowNo
** $$$Tab
+
** A_Tab
** $$$Field
+
** A_Field
** $$$Value
+
** A_Value
** $$$OldValue
+
** A_OldValue
 
+
** A_Ctx
  
 
[[Image:01_BeanShell.png]]
 
[[Image:01_BeanShell.png]]
Line 34: Line 34:
  
 
On the Rule Script:
 
On the Rule Script:
  if ($$$Tab.getValue("Name") != null) {
+
  if (A_Tab.getValue("Name") != null) {
     $$$Tab.setValue("Description", $$$Tab.getValue("Name"));
+
     A_Tab.setValue("Description", A_Tab.getValue("Name"));
 
  }
 
  }
 
  result = "";
 
  result = "";

Revision as of 10:42, 28 January 2008

Status

  • Testing for Next Release 340 - January, 2008
  • A real huge contribution from Carlos Ruiz, Quality Systems & Solutions (QSS), Colombia
  • Now it can work with any java scripting language such as Groovy and Jython, thanks to Víctor Pérez, E-Evolution (Libero), Mexico

Creating the Rule

Within the script you can use:

  • Window context variables start with a W_ prefix
  • Login context variables start with G_ prefix
  • Parameters for callout start with A_ prefix
    • A_WindowNo
    • A_Tab
    • A_Field
    • A_Value
    • A_OldValue
    • A_Ctx

01 BeanShell.png

Configure Callout from Table/Column

02 BeanShellCallout.png

  • This Callout can also be called from the Report & Process Window. Just remember to set in the Rule window from which Event Type are you calling this Rule Script.

Sample Code provided for copy/paste testing

On the Table and Column, callout reference:

@script:beanshell:BP_fillDescriptionFromName

On the Rule Search Key:

beanshell:BP_fillDescriptionFromName

On the Rule Script:

if (A_Tab.getValue("Name") != null) {
    A_Tab.setValue("Description", A_Tab.getValue("Name"));
}
result = "";

Scripting Languages

  • Now standard Adempiere has uploaded jars to work with groovy, jython and beanshell
  • to call a script from a Callout follow these sample syntax:
    • @script:beanshell:ValidateQtyOnHand
    • @script:groovy:ValidateQtyOnHand
    • @script:jython:ValidateQtyOnHand
  • When you create the rule, you have to set in the Search Key such as:
    • Search Key : beanshell:ValidateQtyOnHand
    • Search Key : groovy:ValidateQtyOnHand
    • Search Key : jython:ValidateQtyOnHand
  • Set the Event Type as Callout and Rule Type as JSR 223 Scripting APIs

See Also