CMDBuild Forum

Making Relations mandatory

Hi!

I've been playing with CMDBuild for a while now. I'd like to make relations mandatory upon creation of a new card. Both Class and Relations are defined already I just need it to be mandatory. Our usecase would be that a Rack(Class: Rack) is always in a Room(Class:Room) and the Room is at Colocation(Class:Colocation). 

Do I have to fix this in code or using a type of View?

Thanks,

Andreas Marschke.

In the general case of N:N relationships is not possible to define a mandatory constraint.
However in the case of the 1:N
relationships the simplest solution is to create a “reference” attribute in the class side N and define that attribute as mandatory.
For example, if you created a domain “ColocationRoom” with type 1:N between Colocation” and “Room” and a domain RoomRack” (or rather RoomAsset, using a superclass) with type 1:N between Room” and “Rackthen you must:
-
create a “reference” attribute “Colocation” in the class “Room”, based on the domain ColocationRoom”
- create a “reference” attribute “Room” in the class “Rack”, based on the domain RoomRack”
-
define the two attributes as required
By entering a value into a “reference” attribute it is also automatically created the relationship between the two cards and vice versa.
CMDBuild Team