CMDBuild Forum

Attribute "Nominative" in the Test Database

Hi all,

 

In the pre-filled database, in the Employee class, the attribute "Nominative" is automatically completed when I create a new card with a name and a surname.

 

How is it handled ? I want to recreate the same behavior on a new class but I don't know how can I configure it.

 

Thank you for reading and for helping.

Pierre

You need to use a "calculated field" (Nominative = Surname + ' ' + Name).

 

Since CMDBuild does not have a way to define calculated fields from the user interface at the moment (we will work on this extension next year), in the meantime you have to work directly on the PostgreSQL database by creating manually a custom trigger similar to that of the "demo" database:

 

CREATE OR REPLACE FUNCTION set_data_employee()

   RETURNS trigger AS

$BODY$

   BEGIN

     NEW."Description" = coalesce(NEW."Surname", '') || ' ' || coalesce(NEW."Name", '');

     RETURN NEW;

   END;

$BODY$

   LANGUAGE plpgsql VOLATILE

   COST 100;

ALTER FUNCTION set_data_employee() OWNER TO postgres;

 

CREATE TRIGGER set_data_employee

   BEFORE INSERT OR UPDATE

   ON "Employee"

   FOR EACH ROW

   EXECUTE PROCEDURE set_data_employee();

 

Fabio