instantiate a BDM from Groovy Script and persist it.

I would like create a BDM objects using the provided DAO variable in the groovy script and try to use the created on in the another bdm object and persist it but i am getting error that could get the object using persistence id as null

In Bonitasoft you don’t use DAO to create BDO’s (Business Data Objects) just create them as per this example from the documentation :

var leaveRequest = new com.company.model.LeaveRequest(); leaveRequest.setStartDate(leaveRequestInput.getStartDate()); leaveRequest.setEndDate(leaveRequestInput.getEndDate()); leaveRequest.setReturnDate(leaveRequestInput.getReturnDate()); leaveRequest.setDaysOff(leaveRequestInput.getDaysOff()); leaveRequest.setLeaveType(leaveRequestInput.getLeaveType()); leaveRequest.setApproved(leaveRequestInput.getApproved()); return leaveRequest;

The BDO will persist, that’s the objective of using BDMs in Bonitasoft. You can create in one process and access in another with no problem.

If you are getting the error that could get the object using persistence id as null then you’re doing something wrong.

I would work through the Getting Started Tutorial first to work through and gain understanding of processes and using BDM’s, and then refer to Data which gives a deeper meaning to how to use data and BDM’s in particular.

regards
Seán

PS: If this reply answers your question, please mark as resolved.

How can I I store the available leave days (or dayOFF) of an employee using business data

How can i persist in bdm but i wouldn’t use return leaveRequest;
exemple i wanna just use leaveRequest.persist();
and continue to write my script

its possible ?

This is a design issue that you need to sort out for yourself really.

Personally I might use Organization->Custom Data associated with a user, or use the external HR system we already have in place and interrogate that using the correct methods.

To use BDM though I would create a user BDM with this information in which you can then update accordingly.

regards
Seán