Avoid api.boundCall

Background

api.boundCall() is a super powerful function, however, try to avoid it as much as you can. Configuration full of bound calls is a bad practice for the following reasons:

  • It makes the code more complex and there is a high risk for the project – you never know if the bound call you design will work in future releases.

  • It runs in a different thread, so there may be clashes.

Bound partition must always be set up against some technical account created specifically for the bound call purpose. Never use personal accounts, since these will get removed when a person leaves the company or by the customer during regular security audit checks. The customer is the authority to maintain accounts and therefore should provide an email address for that account since pricefx.eu/com address gets automatically deactivated.

api.backendCall()

In dashboards there is a similar functionality which can execute the REST call from a button in a portlet without the need to configure the bound partition.

Groovy
def payload = api.jsonEncode([
            "data"     : ...,
])
def ctrl = api.newController()
ctrl.addBackendCall(", "add/X", payload, "Record was created sucessfully", "Could not create record")
return ctrl

The drawback of this solution is that the REST call is not done during the logic run, but when the user clicks the button. On the other hand, the benefit is that you do not have to configure the bound partition, which is often "localhost".