#Groovy

Issue with sending a message via sendMessage in a Groovy script

Hello community,

I'm facing an issue while using the `sendMessage` function in a Groovy script to send a message to a Bonita BPM process. But the message doesn't seem to be processed correctly. I would like to mention that I am a beginner in Bonita. I have already taken a look at the documentation, but I am currently stuck.

Here's a simplified example of the script I'm using:

import org.bonitasoft.engine.api.APIAccessor
import org.bonitasoft.engine.api.ProcessAPI
import org.bonitasoft.engine.expression.ExpressionBuilder

Create json for rest API

Hello, I am trying to create a json body for a rest API call, but it returned error

Body as map output cannot be set. Response content type is not json compliant(application/problem+json; charset=utf-8).

I used import groovy.json.JsonBuilder, and created the json as some examples in Q&A, but it doesn't work

How to retrieve attribute from custom query

I created a custom query in BDM queries, it selects the last item in the Param table:

SELECT MAX(p) FROM Param p
ORDER BY p.persistenceId DESC

I'm trying to use this query in a process variable to retrieve the attribute Price, I tried two ways:

parametreDAO.findLastSeuil().price

parametreDAO.findLastSeuil().getPrice()

But I got this error:

org.hibernate.exception.SQLGrammarException: could not extract ResultSet Any idea how to do that?

unable to resolve class à l'exécution d'un script groovy

Lors de l'exécution d'un tâche, une action utilise un script qui se trouve dans les scripts groovy du projet (package jta, script jtaClass.groovy, classe jtaClass)

A l'exécution, bonita génère l'exception suivante : "BScript64.groovy: 1: unable to resolve class jta.JtaClass" sur la ligne "import jta.JtaClass" (C'est l'assistant qui a généré cette ligne)

Pourriez vous m'indiquer comment mettre à jour le CLASSPATH pour corriger cette erreur ?

Find a group by group name with Groovy

I currently use this Groovy script to get the user of a group. Is there any way to simplify this and query a group using the group name directly instead of the full path to the group?

long groupId = identityAPI.getGroupByPath("/amce/hr/mygroup").id
SearchOptionsBuilder builder = new SearchOptionsBuilder(0, 1)
builder.filter(UserSearchDescriptor.GROUP_ID, groupId)
long userId = identityAPI.searchUsers(builder.done())result.get(0).id

How to attach file in disk to an email dynamically?

We tried to attach file by running a script as follows. But, it didn't attach file to the email. Let me know if there are any other ways of doing this or mistakes in this attempt.

import java.io.File;
import java.util.logging.Logger;

File readFile() {
Logger logger = Logger.getLogger("org.bonitasoft");
File file = new File("C:\\Users\\sachinm\\Downloads\\testDoc.txt")
logger.info("File read");
return file;
}

readFile();

How to send data from a form to the pool variable ?

Hey everybody,

I'm new with bonita and I need to set a pool variable with form input. I think I should use groovy scripts in operations tab of my task, but I don't know how to fetch data from current form and assign it to my variable.

can anyone suggest a simple code?

Thanks

How to edit keys and values in connector: Insert data in a .docx/.odt template?

Hello,

Is there any way or example of how to edit the keys and values using a Groovy script, i.e. using the "Edit as an expression" functionality as shown in the attached image, instead of editing them from the table in the connector: Insert data in a .docx/.odt template?

insert-Data-DOCX-1ws2e3e.png

How to obtain the user or possible users in charge of performing a task?

How can I obtain the user or possible users in charge of performing the task called Step2 through a Groovy script? (See attached image)

Mi-Diagrama1-0.png

How to fix this error "Groovy: unexpected token:"?

How to fix this error "Groovy: unexpected token:"? Please let me know how to fix this error. I can't deploy my tutorial claim management tutorial due to this error.

Notifications