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

1
0
-1

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.

Comments

Submitted by antoine.mottier on Mon, 04/08/2019 - 11:17

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

Submitted by cguerram_1396650 on Mon, 04/08/2019 - 18:39

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.

1 answer

1
+1
-1

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.

Comments

Submitted by cguerram_1396650 on Thu, 04/11/2019 - 01:32

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.

Submitted by antoine.mottier on Tue, 04/16/2019 - 08:32

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

Submitted by cguerram_1396650 on Tue, 04/16/2019 - 18:00

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.

Submitted by antoine.mottier on Wed, 04/17/2019 - 13:58

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.

Notifications