Usage of the ejecutarDS Parameter

The ejecutarDS parameter is used to execute a DataSource within another DataSource or within an event. It is used similarly in both the definition of a DataSource and an event.

Important Note

This function is a promise, so it must be used with return and handled with then and catch to properly manage results and potential errors.

Function-Type DataSource Syntax

function dataSourceName() {
  const id = @parameter.id;
  const name = @parameter.nombre;

  return [{ id, name }];
}

return Promise.resolve(dataSourceName());

Usage Syntax

return @ejecutarDS('dataSourceName', { /* parameters */ })
  .then(resultado => {
    // Handle result
  })
  .catch(error => {
    // Handle error
  })
  • The first argument is the name of the DataSource to be executed.
  • The second argument is an object containing the parameters required by the DataSource to perform the query. Although this argument is optional, it must be explicitly defined. If no parameters are sent, an empty object must be passed; otherwise, the function will not work correctly.
  • If parameters are added in the second argument, the keys must be enclosed in quotes, or the function will not work.

Examples

Example 1: Execute a DataSource without parameters:

return @ejecutarDS('getLabelValueFromBanks', {})



Example 2: Execute a DataSource with parameters:

return @ejecutarDS('getLabelValueCiudadesWhereId', {"id": 2})



Example 3: Using other parameters as arguments

If parameters with @, are used, they must be defined as variables beforehand and not sent directly in the second argument object. For example:

const customQuestions = @preguntas()
const customAnswers = @respuestas()

return @ejecutarDS("getDataStructure", {"questions": customQuestions, "answers": customAnswers})



Note

Ensure that the correct DataSource names are provided and that the necessary parameters are passed according to the definition of the DataSource being used.