Skip to content

REST_GetValues

Julio Carneiro edited this page Jan 31, 2018 · 1 revision

The REST_GetValues HTTP Request can be used to execute formulas, or retrieve variables, from 4D side.

That allows for business rules to reside on 4D side, with the web side calling 4D to execute methods, calculate values that depend on your application's business rules.

The POST request payload includes 2 properties:

  • VariablesList: a JSON array of formulas or variables to be calculated/populated on 4D side
  • CallbackMethod: a 4D method, script, to be executed before running thru the VariablesList array, possibly preparing the environment for the calculations to come

The result returned from 4D is the same VariableList JSON Array, but now with values populated for each array item.

Items in the VariablesList array shall have the following attributes:

  • formula: the property is a 4D expression to be calculated, that returns a String value
  • field: the property is the name of a text/alpha field in the database whose value is to be returned; the field name must be on dot long format (table.field); of course the current record must be available, so the record must have been retrieved by the CallbackMethod
  • value: this will contain the calculated value set be 4D on return.

Here is an example VariablesList:

[
  {formula:'ORDRrestCalculaVencimento("20180131";"60 days";true)'}
  {formula: 'String(ORDRrestNextNumeroPedido)'}
]

Please beware that any host method indicated on a formula expression must be set as shared between host and components.

Clone this wiki locally