leave request bonita BPM 7


Hello, I am a beginner Bonita BPM 7, I did a leave request process, I made two model of business data DemandesConges (StartDate, EndDate, dateRetours, NombreJours, TypeConge, balance, MotifConge) and DossierAdministratif (firstName, lastName, Email...), now I want to know how I can calculate balance of leave in such a way that whenever an employee is applying for leave, the balance of leave subtracts the number of days.
I made a script for the variable of pool but plenty of error

import com.company.model.DemandesConges
import com.company.model.DemandesCongesDAO
import org.bonitasoft.engine.api.*
import org.bonitasoft.engine.api.IdentityAPI
import org.bonitasoft.engine.bdm.BusinessObjectDAOFactory
import org.bonitasoft.engine.business.data.SimpleBusinessDataReference
import org.bonitasoft.engine.identity.User
import org.bonitasoft.engine.identity.UserCriterion
import org.bonitasoft.engine.session.APISession
def demandesCongesVar = new com.company.model.DemandesConges()
demandesCongesVar.dateDebut = demandeInput.dateDebut
demandesCongesVar.nombreJours = demandeInput.nombreJours
demandesCongesVar.typeConge = demandeInput.typeConge
demandesCongesVar.motifConge = demandeInput.motifConge
demandesCongesVar.dateFin = demandeInput.dateFin
demandesCongesVar.dateRetours = demandeInput.dateRetours
demandesCongesVar.solde = 22}
else if(demandesCongesVar.getTypeConge()=="maternité"){
        demandesCongesVar.solde = 60
else if(demandesCongesVar.getTypeConge()=="impayé"){
        demandesCongesVar.solde = 20
}else if(demandesCongesVar.getTypeConge()=="paternité"){
        demandesCongesVar.solde = 3
else if(demandesCongesVar.getTypeConge()=="maladie"){
        demandesCongesVar.solde = 25
        demandesCongesVar.solde = 15
double solde = demandesCongesVar.getSolde()
solde = solde - demandesCongesVar.getNombreJours()
def apiSession = PageContext.getApiSession();
BusinessDataAPI businessDataAPI = BusinessDataAPI.getBusinessDataAPI(apiSession);
// Use BusinessDataAPI to retrieve the process instance business variable
// We need to cast it to the appropriate class (SimpleBusinessDataReference or MultipleBusinessDataReference)
SimpleBusinessDataReference businessDataReference = (SimpleBusinessDataReference)businessDataAPI.getProcessBusinessDataReference("vacationAvailable", 2);
// Get storage id (i.e. persistence id) of the business variable
Long storageId = businessDataReference.getStorageId();
// Create DAO factory for the business data
BusinessObjectDAOFactory daoFactory = new BusinessObjectDAOFactory();
DemandesCongesDAO demandesCongesDAO = daoFactory.createDAO(apiSession, DemandesCongesDAO.class);
// Use DAO to find the business variable using the storage id (i.e. persistence id)
DemandesConges demandesConges = demandesCongesDAO.findByPersistenceId(storageId);

//Use the factory to obtain a DAO object

         IdentityAPI identityAPI = apiAccessor.identityAPI
         List<User> users
// For each user
for(DemandesConges demande: demandesConges){
        double soldeEncours=demandesConges.getSolde()
        return soldeEncours

def processInstance = apiAccessor.processAPI.getProcessInstance(processInstanceId)
// Ajouter l'identifiant du demandeur à la nouvelle demande
demandesCongesVar.idDemandeur = processInstance.startedBy
return demandesCongesVar


Submitted by Sean McP on Tue, 04/25/2017 - 21:34

A Tip on displaying CODE/LOGS correctly in Posts:

Do not use the Supplied Buttons above, for some reason they refuse to work correctly, and despite bringing it to Bonitasofts attention, it's low priority.

To Show Code/Logs correctly use

< code >
your code/log
< /code >

removing the spaces to allow the showing of code/logs correctly as here:

your code/log

You should still be able to edit your post to ensure the correct formatting of the code to help us understand it easier.

Thanks and regards

No answers yet.