How to configure a derived columns in the table

yalamanchili_sv
Kilo Contributor

I would like to have derived columns in a table. the value of the column is depending on the other column value. (Example , age which is derived from the data of birth column). please adivse me how to populate the value for the derived column. Thanks in advance..

4 REPLIES 4

geoffcox
Giga Guru

You could use a business rule to calculate the value of the derived column.
The business rule should have the "before insert" and "before update" boxes checked.
This assumes you have added fields called "Birthdate" and "Age":



do_calculate_field_values();

function do_calculate_field_values() {
var x = current.u_birthdate;
var y = f(x);
current.u_age = y;
}

function f(x) {
// your function goes here
}


I hope this helps!

Cheers,
Geoff.


yalamanchili_sv
Kilo Contributor

Geoff,

Thanks a lot for your quick response and advise. Can I have the business rule while genarating the report. I believe if we write the business rule before insert and before update. after few months/years, the age will vary. I would like to have this while genarating the report. is it possible to have this business rule while genarating the report.

I found that, Report can be genarated based on the fileds which are available in the table. please advise. thanks


geoffcox
Giga Guru

You make a really good point. And I think you can achieve what you want by making the business rule a "Before Query" rule instead of before update. I haven't tested it, but the documentation makes it seem that this rule should be executed on records before the report is generated from query data.

Another alternative is using "calculated" fields, but I have had marginal success with them.


Many Thanks Geoff