Get Json url API from javascript var

1
0
-1

Hi, I need to obtain the result of an API query to create and return a new array of objects in a javascript variable of the Form Designer.
I have a custom query that has as parameter the userId but I need to save in an array all the queries of the manager of those userId.

ex.

var inspectores = $data.InspectoresZonales;
var resultado = [];
var obrasinspector = [];
for (var inspector in inspectores)
obrasinspector.push(get("http://localhost:8080/bonita/API/bdm/businessData/com.company.model_Proyectos.Proyectos?q=xInspectorAscOk&p=0&c=100&f=Inspector="+inspectores[inspector].id));
for(var obra in obrasinspector) 
resultado.push(obras[obra]);
return resultado;

the main problem is that I can not get the data from the url.

Please , how can I solve it?

thank in avance
Juan

Comments

Submitted by Dibyajit.Roy on Tue, 03/20/2018 - 19:46

Hi
I dont think you can execute API calls from JavaScript variable.
Usually I create a variable of type API in form Designer. I set the value as /bonita/API/bdm/...
Then , in my javascript, i use ($data.variable) and pass it to the push method.

Submitted by jagch on Tue, 03/20/2018 - 20:21

I do not understand what your solution is, my issue is that I have to execute an API query every time that it results in another var API.

ex.
API identity ["203", "205", "307"]
API query /api/bdm/..../q=query..f=id=203
API query /api/bdm/..../q=query..f=id=205
API query /api/bdm/..../q=query..f=id=307

array result [{obj}, {obj}, {obj}, .........., {obj}, {obj}]

thank you

No answers yet.
Notifications