sql

1
0
-1

good afternoon I have a variable in the UI Designer name caseid type java expression that shows me id of my task then in a widget input you can see everything well. my problem is how much I try to insert into a sql database as I call that variable caseid ?? to insert it in the same way I have in the UI Designer created variables for registered user in pretty, idtarea, name task if I can see my problem is that I do not know how to call them from my connector to insert sql
insert into bon1 (name, date, number, case)
values ​​('$ {ok2.name}', '$ {ok2.date}', $ {ok2.number}, '$ {caseId}')

I have validated that the problem is only the caseid when I put it by default correctly inserted to my sql table I understand that I am not correctly calling the variable

Comments

Submitted by antoine.mottier on Thu, 05/09/2019 - 16:19

Is it a valid option for you to use Business Data Model (BDM) feature provided by Bonita? BDM allow you to easily create a definition of your database tables and at the same time create Java classes to manipulate the data from the process definition. When executing the process in the test environment provided by Bonita Studio, BDM will use an embedded h2 database to store the data. In production you will be able to use MySQL, PostgreSQL, Oracle and SQL Server.

If this option is valid I can provide an example of process that let you enter the data in a form, save them in the BDM, display them in another form and allow the user to edit same and save again the modification by updating the BDM.

If BDM is not a valid option for you, saving the data will be quite easy (using a Bonita connector) but displaying them is a little bit trickier as it involves usage of a REST API extension.

Submitted by morongarciakaty... on Thu, 05/09/2019 - 16:54

si estoy usando BDM que contiene nombre, fecha, número, caso . Pero en el contrato solo pongo nombre, fecha, número ya que esos datos serán llenados , en cambio "caso" lo que trato de hacer es que jale automáticamente el nombre de mi tarea (por ejemplo mi proceso solo tiene una tarea llamada "prueba caso" lo que buscaba es que formulario jalo un widget (input solo lectura) muestre "prueba caso") si lo logro que se que muestre en mi formulario he creado estas variables :

nombre variable valor tipo
prueba1 return $data.miTarea1.name tipo java expresion
miTarea1 ../API/bpm/task/{{taskId}} external api

en mi widget (input solo lectura ) lo llamo en las propiedad valor :prueba1

Cuando lo ejecuto si lo llego a ver pero mi problema esta al insertar SQL no se como llamarlo
insert into bon1 (nombre, fecha, número, caso)
valores ('$ {ok2.name}', '$ {ok2.date}', $ {ok2.number}, '$ {prueba1}')

porfavor me puedes ayudar

Submitted by morongarciakaty... on Thu, 05/09/2019 - 17:20

este es el link puedes ayudrame porfa

Submitted by antoine.mottier on Thu, 05/09/2019 - 20:08

First quick comment: if you are using BDM feature you probably don't need to use a SQL Server connector. When later you will install your Bonita production server you can configure the BDM to use SQL Server instead of the default h2 database used when running process in Bonita Studio.

1 answer

1
0
-1

So if I understand correctly you want to update the value of a process business variable with a value that is not provided by the user in a form. Instead you want to use a value managed by Bonita (such as the name of a task in a process definition or the id of a process instance).

In your example the name of the business variable is ok2 and the type of this business variable is Ok. Ok is a simple business object with 5 attributes: nombre, fecha, numero, aprobar and caso.

Value of nombre, fecha and numero are provided by the user and you want for example to set the value of the attribute caso with the process instance id (i.e. the case id) that is automatically generated by Bonita. Note that the process instance id data type is Long whereas caso attribute data type is String so a type conversion will be needed.

To set the value of caso attribute of the business variable ok2 in the task "prueba caso", you need to add an "operation":

  1. Select the task
  2. Go in "Execution" -> "Operations" tab (you can see some automatically generated operations that use step contract input to update the business variable attributes)
  3. Click on "Add" button to add a new operation
  4. Select the process variable ok2 in the left drop down list
  5. Click on the "Takes value of" link and change the operator type to "Use a Java method"
  6. Select "setCaso"
  7. Click on the pencil icon on the right
  8. Choose "Script"
  9. Enter the script that will convert the process instance id from Long to String type: processInstanceId.toString() (processInstanceId is a variable provide by the Bonita Engine when executing the process)

Now if you run this process you should see the value of the process instance id stored in the database (you can see that by going in Studio menu "Development" -> "Business Data Model" -> "Browse data (h2 console)...".

If you want to display the business variable information for example in the form of a task you add at the end of the process you need to:

  1. Create a new form variable
  2. Set the name, for example: okForm
  3. Set the type to "External API"
  4. Set the API URL to: ../{{context.ok2_ref.link}}
  5. Add widgets to your form. For example: an input widget
  6. Set widget read-only option to "yes"
  7. Set the widget value property to: okForm.caso

Here we are duplicating the information about the process instance id (already stored in Bonita Engine database) in the BDM. Instead of doing that we usually call the Engine API for example with this URL ../API/bpm/userTask/{{taskId}} ({{taskId}} will be replace by the taskId form variable value itself initialized using the value available in the URL that load the task form).

Comments

Submitted by morongarciakaty... on Thu, 05/09/2019 - 21:32

hola muchas gracias he probado processInstanceId.toString() y me guardado en mi base de datos el ID CASO muy bien .una consulta mas si tambien deseo guardar el usuario que se logea de bonita y nombre de la tarea. como puedo hacer porque solo veo activityInstanceId varias que termienan id entiendo que solo me brindara el id pero si quiero el nombre ????

Submitted by antoine.mottier on Mon, 05/13/2019 - 09:28

On a task you have the information about the user who claimed the task and submit it using the taskAssigneeId variable. Using the apiAccessor variable you can access to the API. And using the IdentityAPI you can get a User object that old user information such as first name... : apiAccessor.identityAPI.getUser(taskAssigneeId).firstName

If you need information about the user who start the process you can do: BonitaUsers.getProcessInstanceInitiator(apiAccessor,processInstanceId)

Submitted by morongarciakaty... on Mon, 05/13/2019 - 16:19

hola antoine.mottier muchas gracias ya puedo obtener el usuario pero como hago para el nombre de la tarea me explico mi proceso tiene dos tareas llamadas ingresar y validar como hago para que guarde ese nombre "validar"?? puedes ayudarme porfavor
graciasss

Submitted by antoine.mottier on Mon, 05/13/2019 - 18:59

You need to use the processAPI (available using the apiAccessor, just like identityAPI). On processAPI you can get a HumanTaskInstance object using the getHumanTaskInstance that requires the id of the task instance as a parameter. On the HumanTaskInstance object you can then call the method getDisplayName.

Submitted by morongarciakaty... on Tue, 05/21/2019 - 16:15

muchas gracias antoine.mottier ya me salio
sabes como podria obtener el correo?? del usuario que se loguea en bonita (ya lo puse manualmente el correo) pero no se como llamarlo. es decir tengo una tarea que una vez rechazado la cotizacion manda un correo pero lo que quiero es que mande el correo de la persona que mande la tarea
me explico tengo una tarea A que ingresa cotizacion ( dos usuarios pueden ingresar a esta tarea) luego tengo una tarea B que evalua si rechaza deberia enviar correo a los usuarios q han ingresado la cotizacion

Submitted by antoine.mottier on Tue, 05/21/2019 - 19:25

Please for a different question don't use post a comment but instead create a new question.

Actually you already create a new question: https://community.bonitasoft.com/questions-and-answers/email

So please avoid to create multiple comments and questions on a same topic. You will not get an answer faster.

Notifications