Skip to Content

mvSQL Runtime Function - CALLER()

Summary

The current row's columns can be made available to the data objects downstream. This function can then access these values in several locations.

Caller() can be used in expressions on CRUD Rules within Events, Success Handlers, or Error Handlers. When the Caller() function is used on a Success or Error Handler the Action will look for a given field from the Action Rule it is running from. When the Caller() function is used on an Action Rule, it looks at field values from the record on the Business Object the Event is running on. See the Example Usage with Success Handler for clarification.

New in Vinyl 3.3, runtime functions can return more than a string if a type parameter is specified.

Note

This mvSQL function will only work on CRUD Rules, and not with other data objects created in Vinyl.

Syntax

CALLER(<name> [, datatype>])

Parameters

name

A string representing the requested criteria's name.

datatype

Data type, string is default, optional. Supported datatypes:

  • String (default)
  • Numeric
  • UUID

Returns

Runtime functions always return a SQL string. They do not return NULL. Instead, they return an "empty" value. The type parameter determines which empty value is returned:

  • An empty String returns ''
  • An empty Numeric returns '0' in 3.2, 0 in 3.3
  • An empty UUID returns '00000000-0000-0000-0000-000000000000' in 3.2, uuid('00000000-0000-0000-0000-000000000000') in 3.3

Remarks

The CALLER() function always returns a SQL string.

Examples

Example Targeting Another Table

  • A row from the Customer table has an Uppercase event that targets another table.

This rule could be created:

SELECT UPPER(CALLER('CustomerName')) as UppercasedName FROM CustomerArchive

Which would evalulate at runtime to:

SELECT UPPER('John Doe') as UppercasedName FROM CustomerArchive

Example Usage with Success Handler

  • Business Object '123' has an Event named 'event'
  • 'event' has a Rule type Action with the Rule 'abc'
  • 'abc' has a Success Handler Event, where Action of Rule-type has Rule 'def'
  • 'def' has an Expression Caller('uuid')
  • Caller('uuid') targets the PK of the Target Table for 'def' with 'bind' as the Target type
  • 'uuid' from Caller('uuid') exists by name only in 'abc', not Business Object '123'
  • In the appropriate scenario, the Success Handler fires and successfully updates the appropriate record in the Target Table of 'def' according to the Rule