creating employee groups with existing employees


i have employee entity of 1000 records with fields like id,name,department,Contact

i want to create employee groups by entering title,description and  selecting few employees in list drop down box linked to select2 widget 

please help me how to do this.

Hello Dinesh.

You said what you want to do.

In order to us to be able to help you, you need to provide more information, like, how are you trying to implement this code, and what is the problem you're facing.

Without knowing what is your difficult, we can't help.


Hi Eduardo,

While creating the group when i select few employees in the list box select2  drop down  and click on save it is not adding the selected employees to the default users

i have attached the Oml which i am working  

please help me.


Hello Dinesh,

You have a big logic problem. See your code:

The problem is in that aggregate. You see, the ListBox widget has its own List. Every change you do to the List (to the selected items) will reflect there. So, it's for this list that you have to look.

It will be required a small change in the code, as you will have to iterate this list and check which items are selected, OR you filter this list and do the iteration in the result list (kind of the same philosophy you're using.

Something like this (do not implement this yet):

This will now make your code work "partially":

But notice the above code has now another BIG problem.

The above works for NEW groups, but it will fail for EXISTING groups. 

First, when you enter an existing group, you are not showing the existing associated users.
And if you try to associate an user that is already associated, you can do it, and it will create "duplicates" in your database:

So, you also need to change the logic of your application to:

1. On existing group, SHOW the users already selected in the list box.
This will require changes in the preparation aggregate that is the source for the ListBox

2. Change the save logic to be able to UPDATE an existing record, not only to be able to add users to a NEW group.
This will require you to think how to deal with both situations. The logic will be different for each one.

I'll let you work on those two steps. If you find any problems come back here, show us what you did and where are you strugling.

Also, remember to use the Debugger. It will help you find logic problems also.