How can I get All Parameters from a groovy Script?
I want to get Process Parameters from a groovy Script to write them to a File but it seems they are not know if they are not included manually in the script.
I don't want to add all of them manually, I need to have a dynamic List.
I've try:
import org.bonitasoft.engine.api.APIAccessor
import org.bonitasoft.engine.bpm.parameter.ParameterCriterio
import org.bonitasoft.engine.api.ProcessManagementAPI
File file = new File("/var/tmp/out.txt")
parameters = apiAccessor.processAPI.getParameterInstances(processDefinitionId, 0, 100, ParameterCriterion.NAME_ASC)
parameters.each {
varname = it.name
file.append(varname + ": " + evaluate("$varname") + "\n")
}
This Method don't works. I have to add an access to each parameters in the script to make it works (parameters are Param1 and Param2 in the example)
import org.bonitasoft.engine.api.APIAccessor
import org.bonitasoft.engine.bpm.parameter.ParameterCriterio
import org.bonitasoft.engine.api.ProcessManagementAPI
File file = new File("/var/tmp/out.txt")
xx = Param1
xx = Param2
parameters = apiAccessor.processAPI.getParameterInstances(processDefinitionId, 0, 100, ParameterCriterion.NAME_ASC)
parameters.each {
varname = it.name
file.append(varname + ": " + evaluate("$varname") + "\n")
}
How can I get a dynamic Parameters List?
Best Regards
The method apiAccessor.processAPI.getParameterInstances(processDefinitionId, 0, 100, ParameterCriterion.NAME_ASC) does return a list of parameters for a specific processDefinitionId.
What is the error you get?
Hint, try first to just save the parameters info into a processVariable or log them in the log.
When this works fine, write them into a file.
I did the following:
import org.bonitasoft.engine.bpm.parameter.ParameterCriterion def myOutput def processWithParamsId = apiAccessor.getProcessAPI().getProcessDefinitionId("ProcessWithParams", "1.0")def myParams = apiAccessor.getProcessAPI().getParameterInstances(processWithParamsId, 0, 10, ParameterCriterion.NAME_ASC) myParams.each {
myOutput += it.name
myOutput += " --- " + it.value
myOutput += "\n"
}
return myOutput
where myOutput is mapped to a process variable and I can see the parameters names and values passed to this variable