So, I’m trying to run a service task where the application verifies if a user has filled out a BDM. So I need to query by current user and verify whether the database of BDM’s is empty. Any ideas how to do this? This should return a boolean value to help direct the user to either do an initial setup or go on to the main tasks.
Thanks!
My thoughts on this are that this is not actually possible…
The reasoning is that when you export a process it will automatically take a copy of the BDM with it. Therefore the BDM will actually exist.
I think what your really asking is does the database hold a completed BD Object (BDO), built from a BDM.
And in this respect you can simply use a script connector and use the built in BDM.DAO calls to determine if there is a completed BDO for the data you are hoping they have initialized.
best regards
Seán
PS: If this reply answers your question, please mark a resolved.
Sean, thank you for your reply.
What I’m trying to do is test the condition within the UI designer by calling the API getting the value of my key id (starts at one) and then write the code in a javascript variable checking if it’s less than one. I don’t know if there is anyway to check if the object “array” is null or empty.
???
In the question you say …I’m trying to run a service task…
And then you say …I’m trying to do is test the condition within the UI designer…
From my point of view I think your making it too complex…my take on this would be
Start
Perform Service Task to determine if BDO is complete, True or False
Gateway - if false then Perform This Task ELSE Perform Main Tasks
Done
No need for API’s getting KeyIds or JavaScript…
regards
Seán
Thanks Sean. I tried that but I was getting errors. I must be using the wrong syntax:
if (detailMacroObjsDAO!=null){
return true;
}
else
return false;`
That’s why I thought that I could alternatively use the UI.
This is the code I ended up using. Is there a better way? (Having such a hard time finding how to find the current user in Groovy. I couldn’t figure out how to use com.bonitasoft.engine.session.Session and no clues in the community.)
Thanks for all your help!
import org.bonitasoft.engine.session.Session;
import com.workcompanion.data.DetailMacroObjs;
import com.workcompanion.data.DetailProjects;
String currentUser = "";
currentUser = BonitaUsers.getProcessInstanceInitiator(apiAccessor,processInstanceId).userName;
List<DetailMacroObjs> macroObjs = detailMacroObjsDAO.findByMacroObjUser(currentUser,0,100);
List<DetailProjects> projects = detailProjectsDAO.findByProjectUser(currentUser,0,100);
if (macroObjs!=null && macroObjs.size()<1 && projects!=null && projects.size()<1){
return false;
}
else
return true;
Looks fine to me, well done…