Register new Function

Beas script can be defined to executed, if you call the function.

Use this as small "Rest Service calls"

 

Call this with

get [entityname]/[functionname](parameter)

 

First define the function in the Object

[register collections]
CompanyWorkOrderActivity=primary=ClgCode/n<tab>description=Activity for Work order
[/register collections]
 

 

In Object defintion define with "Function" the new function

Follow Properties are available

Property

Description

name

Function name

description

Function description

parameter

Defines the parameter

ParameterName/type,

ParameterName/type

 

The field type

c=char

i=integer/numeric

d=date

b=boolean
 
Example
Color/c,Width/i

 

 

Example

// Define all Columns, Functions, Table and other properties
[register CompanyWorkOrderActivity]
table=OCLG
post=true
column=name=ActivityCode<tab>sql="OCLG"."ClgCode"<tab>fieldtype=i
column=name=Details<tab>sql="OCLG"."Details"<tab>maxlength=20

// Define function without Parameter
function=name=CountOfEntries<tab>description=Return count of existing activities
// Define function with parameter
function=name=AddValues<tab>description=Add 2 values<tab>parameter=value1/i,value2/i
function=name=ItemInfo<tab>description=Return Item Info<tab>parameter=e_itemcode/c
[/register CompanyWorkOrderActivity]

 

In the Area [object/FunctionName] you can define the function

BeasScript: All Parameters defined as String Variables. All return values are string variables.

JBScript: All Parameters defined as local variable. You can return all variables as "simple" variable. Objects not allowed

 

Follow variables you can define for the return

Variable

Description

result

Define the string, which the system has to return

Example:

[register CompanyWorkOrderActivity]

function=name=AddValues<tab>description=Add 2 values<tab>parameter=value1/i,value2/i
[/register CompanyWorkOrderActivity]

 

 

beasscript-logo-small

[CompanyWorkOrderActivity/AddValues]

// Add Parameter 1 with Parameter 2
setvar=result=%numadd(<value1>,<value2>)
[/CompanyWorkOrderActivity/AddValues]     

 

 

GET CompanyWorkOrderActivity/AddValues(3,4)  -> Return "7"

 

sql (only beas script)

sqljson

Syntax:

beasscript-logo-small

setvar=sql=.select command

 

or better (2021.05 or later)

setvar=sqljson=.select command

 

Note: if variable value start with "select", the system return the result of sql statement. For correct definition the value must start the select command with point

setvar=sqljoin=.select ...

 

Example:

// e_itemcode is the parameter
setvar=sqljson=.select "ItemName" from "OITM" where &
                     "ItemCode"=<e_itemcode,dbstring>

 

code

Return the code (the default is 200 = ok. . If this is modified, it results in an error.

messagecode / message

Define the error code and error message, if the code is not 200

Note: The system display message only, if you end the function with

return failure  (JBS: return -1)