Calculate a field value based on other table fields

sek86
Tera Contributor

Hi,

I have a requirement to calculate a field value based on the fields from other table.

for example, i have column total_cost in Definition table the value of this column has to be storage cost + license cost (which are columns in Specifications table) + hourly price (which is a column in billing table)

Could you help me with this.

2 REPLIES 2

Matt102
Giga Guru

Hi,

My first try would be on the sys_dictionary field for definition_table.total_cost

Go to that record and then tick the Calculated checkbox in the Calculated Value Tab

Then write a script to get the calculated value from the other two tables...

HTH,Matt

BharathChintala
Mega Sage

Hi Sek,

 

Do you have any relation between these tables? If yes write before insert and update Business rule on Billing table

 

in advanced  

var gr = new GlideRecord("Definition table");

gr.addQuery("billing relation field",current.sys_id);

gr.query();

if(gr.next()){

current.total = parseFloat(gr.storagecost + gr.licensecost+ current.hourlyprice);

}

 

This if you have to update field in Billing table. Or if you want to update different please give requirement clearly I will help.

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala