Custom Table - Dictionary Table - Calculated Value

Andres25
Giga Contributor

Hello,

I have a custom table with one field (u_result) that I want to be calculated based on boolean value of two other columns of the same table.

Something like:

If u_boolean1 == true and u_boolean2 == true 

u_result == true

I have seen that the calculated value feature of the dictionary entry has the script option but I'm not familiar at all with syntaxis. 

What would be the code for creating a function that validates both boolean values and if both are true set the result field to true otherwise set to false?

Thanks,
Andres.

1 ACCEPTED SOLUTION

MrMuhammad
Giga Sage

HI Andres,

Calculated value has huge impact on performance. Calculated fields are calculated every time a row is read. This means any calculation that does complex processing is re-run on every row read. In an example with 100 rows, that means a calculated field, even one which isn't displayed on your list, is calculated once per row or 100 times per list. Often you can get the same results, and better performance by using an Insert/Update business rule to set a field value, rather than relying on a calculated field.

 

if you want to calculate the value on form Load or on value change you can go with Client scripts. If you want to calculate value on insert or update then you should choose to go with business rule. 

 

Client script structure

if(field_1 == true && field_2 == true)
   g_form.setValue('u_result', true);

 

 

Business rule structure

var field1 = current.field_1;
var field2 = current.field_2;

if(field1 == true && field2 == true)
  current.u_result = true;

 

Let me know which route you wanted to go, I will help you further on that if required.

 

Please mark this correct & helpful if it answered your question.

Thanks & Regards,
Sharjeel

 

Regards,
Muhammad

View solution in original post

6 REPLIES 6

sachin_namjoshi
Kilo Patron
Kilo Patron

You can configure calculated field.

But, calculated field will work on every update to the record and it may hamper performance.

 

Instead , you should configure business rule to update your custom field value like below code

 

 

If (current.u_boolean1 == true && current.u_boolean2 == true)

current.u_result = "true";

MrMuhammad
Giga Sage

HI Andres,

Calculated value has huge impact on performance. Calculated fields are calculated every time a row is read. This means any calculation that does complex processing is re-run on every row read. In an example with 100 rows, that means a calculated field, even one which isn't displayed on your list, is calculated once per row or 100 times per list. Often you can get the same results, and better performance by using an Insert/Update business rule to set a field value, rather than relying on a calculated field.

 

if you want to calculate the value on form Load or on value change you can go with Client scripts. If you want to calculate value on insert or update then you should choose to go with business rule. 

 

Client script structure

if(field_1 == true && field_2 == true)
   g_form.setValue('u_result', true);

 

 

Business rule structure

var field1 = current.field_1;
var field2 = current.field_2;

if(field1 == true && field2 == true)
  current.u_result = true;

 

Let me know which route you wanted to go, I will help you further on that if required.

 

Please mark this correct & helpful if it answered your question.

Thanks & Regards,
Sharjeel

 

Regards,
Muhammad

-:)

Both answers were very helpful thank you!