Bonita web form doesn't show the value of previous activity

I’m new to bonita. I’m trying to set a value in a “select” field using the formInput variable.

This is the definition of the formInput variable:

if ($data.request != null){
return {
“solicitudPlanningInput” : {
“nombreRequerimiento” : $data.request.gerenciaSolicita,
“capaRed” : $data.request.capaRed,
“gerenciaSolicita” : $data.request.gerenciaSolicita,
“prioridad” : $data.request.prioridad,
“areaSolicita” : $data.request.areaSolicita,
“tipoRequeremiento” : $data.request.tipoRequeremiento,
“requerimientoEn” : $data.request.requerimientoEn,
“nombreSitio” : $data.request.nombreSitio,
“IDSitio” : $data.request.IDSitio,
“latitud” : $data.request.latitud,
“longitud” : $data.request.longitud,
“motivosRequerimiento” : $data.request.motivosRequerimiento,
“solicitudEjecutada” : $data.SolicitudEjecutadaRule,
“atpValidado” : $data.ATPValidadoRule,
“procedeCorreccion” : $data.ProcedeCorreccionRule
}
};
}
else{
return {
“solicitudPlanningInput” : {
“nombreRequerimiento” : null,
“capaRed” : null,
“gerenciaSolicita” : null,
“prioridad” : null,
“areaSolicita” : null,
“tipoRequeremiento” : null,
“requerimientoEn” : null,
“nombreSitio” : null,
“IDSitio” : null,
“latitud” : null,
“longitud” : null,
“motivosRequerimiento” : null,
“solicitudEjecutada” : null,
“atpValidado” : null,
“procedeCorreccion” : null
}
};
}

This is the definition of request variable:

if ($data.context != null){
var xmlHttp = new XMLHttpRequest();
var url = window.location.origin+“/bonita/”+$data.context.solicitudPlanning_ref.link;
xmlHttp.open( “GET”, url, false);
xmlHttp.send( null );
var response = JSON.parse(xmlHttp.responseText);
return response;
}
else{
return null;
}

This is the definition of context variable:

if ($data.taskId != null){
var xmlHttp = new XMLHttpRequest();
var url = window.location.origin+“/bonita/API/bpm/userTask/”+$data.taskId+“/context”;
xmlHttp.open( “GET”, url, false);
xmlHttp.send( null );
var response = JSON.parse(xmlHttp.responseText);
return response;
}
else{
return null;
}

This is the definition of taskId:

var href = window.location.href;
var url = new URL(href);
var taskId = url.searchParams.get(“id”);
return taskId;

When I execute a console.log($data.request) it returns the values of the previous activity, but the problem is that the values of the “select” inputs are not reflected in those fields. If I assign the values of those “select” inputs to a input text field, it reflects the value that comes in the $data.request.

Does anyone know what could be wrong?

Im currently using Bonita 7.8.3.

Thank you.

I create a basic example to illustrate usage of select widget using variables local to the form.

Maybe this example oversimplify your use case. If need I can make an evolution of this example to illustrate how available values can be initialized with data stored in Bonita Business Data Management (BDM) service.

Hi,

Just to make I correctly understand your use case, can you confirm if you want to:

  1. Define the list of possible values of your select widget
  2. or define the selected value in your select widget?

Thanks

Hi, thank you for your answer.

In this use case I want to define the selected value in the select widget.

The list of possible values is defined by a JSON variable, which is associated to the select widget.

Regards.

Thank you. I would appreciate if you can make the example with data stored in Bonita BDM.

I’m trying to apply your example to my use case. I’ll let you know if I find any issue.

Here is a second example that use BDM information (retrieved using a REST API call) to populate a select widget.

Thank you. When I execute the form, the widget doesn’t get the possible values. After importing the .bos, does I need to do some inserts or something to the database? Actually, I’m using the Community Edition with the defaul H2 database.

The .bos file includes two processes. You first need to run the CreateColors process in order to initialize the BDM values in the database. Then you can run the SelectColorInitialGreen process that will display the form with the list of colors id in a select widget and the initial value of this widget being the id of the green color.