About Script Engine and Script

You can call JVM-based scripting languages from within LPL. JavaScript is built into the JVM, and Groovy is delivered with Landmark. The system can support additional languages such as Clojure, Scala, JRuby, and Jython.

Enable a Script Engine for an application data area. Upload scripts to run on engine you activate and then call the script from your configurations. For example, you can build action entrance and exit rules that can step outside of the Landmark system for access to additional services or you call script methods from derived fields to derive a value from outside of the system, such as a web service.

Example: Derived Field

Script example

CurrentTemperature is a DerivedField
    type is Numeric size 3
    return WEATHER.getTemp(ZipCode) in script "Weather"

Display rule script example

display "TheCurrentTemperatureIs<getTemp(ZipCode) in script "Weather">"

Groovy script defined as WEATHER in Script:

@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )

import groovyx.net.http.*
import groovy.json.*
import static groovyx.net.http.Method.GET
import static groovyx.net.http.ContentType.JSON

def String getTemp(Integer zipcode)
{
    def temp = ""    if (zipcode != 0)
    {
        temp = '*'
        def http = new HTTPBuilder('http://api.openweathermap.org')
        http.request( GET, JSON ) {
            uri.path = '/data/2.5/weather'
            uri.query = [ q: zipcode + ',USA' ]
 
            response.success = { resp, json ->
                temp = ((json.main.temp - 273.15) * 1.80) + 32.00
            }
       }
   }
   return temp 
}

Example: Invoke Script

invoke script rule Example.conformation()

Groovy script defined as EXAMPLE in Script:

def void confirmation()
{
    Infor.confirmation("Are you sure you want to do this?")
}