RequestFormevent

From TempusServa wiki
Jump to navigation Jump to search

This Codeunit is not ready for use!

What it does

This codeunit is capable of performing an HTTP-request with parameters from the updated item and update the item based on the result.

How to invoke

Add the codeunit dk.tempusserva.codeunit.common.RequestFormevent to the entity and add a configuration named RequestFormevent.Setup with content based on the following configuration.

It is possible to add both a "before-update" and an "after-update" action.

Configuration

Datapoint Type Notes
when Required String Possible values: "after-update" or "before-update".

Determines whether the call is executed before or after an item is updated.

status Optional Array An array of the StatusID's where the call should be executed.

If "after-update", then this is if the item is in one of these status's after the update, likewise for "before-update".

If not given, then the call is executed every time.

call Required The actual configuration of the call.
call.url Required String The url that is to be called. This supports input of parameters from the item.
call.method Optional String The HTTP-method of the call, one of: "POST", "GET", "PUT" or "DELETE". Default: "GET".
call.type Optional String The datatype of data returned, supported types: "json", "raw" or "XML". Default: "json".
call.headers Optional Map A map of extra headers that should be set
call.params Optional Map Path parameters that should be set and send.
call.body Optional String A string that will be set and send. Not available for "GET".
call.update Optional Map Fields that should be updated based on the data returned.

If type is "raw", only the first item in this list will be updated, and it will be set to the entire response.

Sample

[
    {
        "when": "before-update",
        "status": [69],
        "call": {
            "url": "https://acme.com/resource/[ID]",
            "method": "GET",
            "type": "json",
            "headers": {
                "Authorization": "Bearer XYZ"
            },
            "params": {
                "param": "[DATA]"
            },
            "body": "",
            "update": {
                "[LINK]": "info.link",
                "[NAME]": "info.name"
            }
        }
    }
]

Developer info

  • Type: CodeunitFormevent
  • Security: Requires session