How to access to a Business Object?

Hi,

I’m trying to get access to a row in a Businnes Object from an external process (I cannot access from context) but I cannot do this, I get the following exception:

{"exception":"class org.bonitasoft.engine.bpm.process.ProcessExecutionException","message":"USERNAME=walter.bates | org.bonitasoft.engine.core.process.instance.api.exceptions.SProcessInstanceCreationException: PROCESS_DEFINITION_ID=5085018177039517831 | PROCESS_NAME=Edit supplier | PROCESS_VERSION=0.0 | org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: groovy.lang.MissingMethodException: No signature of method: static com.company.model.SupplierDAO.findById() is applicable for argument types: (java.lang.Long) values: [49]\nPossible solutions: findAll(), find(), findAll(groovy.lang.Closure), find(groovy.lang.Closure)"}

This is my code:

import com.company.model.Supplier; import com.company.model.SupplierDAO;

Supplier sp = SupplierDAO.findById(Long.parseLong(supplierSupplier.get(“persistenceId”)));
sp.setName(supplierSupplier.get(“name”));
sp.setDescription(supplierSupplier.get(“description”));
return sp;

What’s wrong with my code?, am I trying to access properly?

===== UPDATE =====

This is so frustrating, I’m trying to access via query, but I get this error:

Error: {"exception":"class org.bonitasoft.engine.bpm.process.ProcessExecutionException","message":"USERNAME=walter.bates | org.bonitasoft.engine.core.process.instance.api.exceptions.SProcessInstanceCreationException: PROCESS_DEFINITION_ID=5317399391776196580 | PROCESS_NAME=Edit supplier | PROCESS_VERSION=0.0 | org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: PROCESS_INSTANCE_ID=3 | Declared return type class com.company.model.Supplier is not compatible with evaluated type class com.company.model.Supplier_$$_jvst635_9a for expression Supplier.findById"}

??? :frowning:

===============
Thanks in advance.

Did you find the solution to this problem, same thing happens on my part

 

 

Hi,
try casting the persistence id into long like this, and be carefull to use ‘supplierDAO’ and not ‘SupplierDAO’

import com.company.model.Supplier; import com.company.model.SupplierDAO;

Supplier sp = supplierDAO.findById(supplierSupplier.persistenceId.toLong())
sp.name = supplierSupplier.name
sp.description= supplierSupplier.description
return sp;

Hi Romain,

Thanks for your comment. I tried it but I got this:

Error: {"exception":"class org.bonitasoft.engine.bpm.process.ProcessExecutionException","message":"USERNAME=walter.bates | org.bonitasoft.engine.core.process.instance.api.exceptions.SProcessInstanceCreationException: PROCESS_DEFINITION_ID=5207291381939884011 | PROCESS_NAME=Edit supplier | PROCESS_VERSION=0.0 | org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: PROCESS_INSTANCE_ID=11 | Declared return type interface com.company.model.SupplierDAO is not compatible with evaluated type class com.company.model.server.SupplierDAOImpl for expression supplierDAO"}