CMDBuild Forum

How to tag Code attribute to Description attribute in any Class

Could you please tell me how to tag Code attribute to Description attribute in any class ? Only some classes have this relation of attributes. Other classes or a newly created class do not show this relation of attributes. This relation helps to identity the code(number) allotted to description(name).

Creating & executing the following trigger function in PgAdmin of Postgres database will concatenate the attributes of any class.

CREATE OR REPLACE FUNCTION Test()
RETURNS TRIGGER
AS $$
BEGIN
NEW.“Description” = left(concat_ws(’ - ', NEW.“Code”, NEW.“Name”), 250);
RETURN NEW;
END;

$$ language ‘plpgsql’;

CREATE TRIGGER Testtrigger
BEFORE INSERT OR UPDATE ON “ClassName”
FOR EACH ROW
EXECUTE PROCEDURE Test();

If the above trigger needs to removed, then below query can be executed.

DROP TRIGGER Testtrigger on “ClassName”

1 Like

thank you for your help