CMDBuild Forum

Who is populating hidden fields?

Hi,

I am analyzing a configuration of Ready2Use.

For example, an employee “t.smith” is a manager of department “DEVELOPER_1” (class “Organizational unit” is related through domain “ManagerOU” with Employee).

In “Employee” class attribute “Description” is hidden.

Tom’s card looks like this:

image

Please notice that there are no combined field that contains last and first name.

“Organizational unit” has an attribute “Manager” that is of type “reference” by domain “ManagerOU”.

Now when you look at the picture bellow:

image

You can see that list of values is in format “Last First”.

If I look in the database table “Employee”, I can see that Tom’s record has field Description populated.

Name         |Value              |
-------------|-------------------|
Id           |6079               |
IdClass      |"InternalEmployee" |
Code         |t.smith            |
Description  |Smith Tom          |
Status       |A                  |
User         |admin              |
BeginDate    |2015-06-09 16:31:50|
Notes        |                   |
EndDate      |                   |
CurrentId    |6079               |
IdTenant     |                   |
LastName     |Smith              |
FirstName    |Tom                |
Email        |t.smith@example.com|
Phone        |                   |
State        |108                |
Type         |                   |
ContractEnd  |                   |
OU           |6069               |
ContractStart|                   |
Company      |                   |
Mobile       |                   |
Number       |IE0210             |

My question is, what magic has populated field Description if it is hidden?
It couldn’t be done by hand because the user doesn’t have an access to this field.
How to use another two (or more) fields as a description?

Regards.

I found a trigger:

CREATE OR REPLACE FUNCTION public.tt_employee_descr()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
–RAISE NOTICE ‘Trigger % on %’, TG_NAME, TG_TABLE_NAME;

NEW."Description" = concat_ws(' ', initcap(NEW."LastName"),initcap(NEW."FirstName"));
RETURN NEW;

END;
$function$

Should this trigger be added manually or I can setup cmdbuild in order to create this trigger automatically?

1 Like

I do not know of a way to have the trigger automatically be set up. I have PG Admin and have a couple of description triggers I use depending on if I want to include the code or some other information like the department.
If your description is the same as the name instead of creating a name attribute just rename the display name for Description to Name and use that.

image