CMDBuild Forum

Automatically set the value of an attribute based on the value of other attributes

Dear all, problem: a “Codice Ambiente” attribute of an “Ambiente” class is automatically populated based on the selection made on the other two fields “Progetto” and “TipoAmbiente” by setting the following Javascript code in the Other Properties field “Auto Value”.

api.bind = [“Progetto”, “TipoAmbiente”];
api.setValue ("" + api.getLookupCode (“Progetto”) + “-” + api.getLookupCode (“TipoAmbiente”));

Everything works regularly if I act from the “Ambiente” class by adding a new one, while if I start from the “Progetto” class and navigate the relationship with “Ambiente” when the tab is opened the “Progetto” field is correctly valued but without this value being reported in the “Codice Ambiente” field and being in display only, nothing can be done.

image

How can I solve this problem?

Thanks in advance.
Roberto

Not sure what are your requirements, but I have solved this by switching from Auto Value (which is known to lag execution - hence your observations) to Form Triggers (After *).