Calculate a field value based on other table fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2023 03:30 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2023 04:04 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2023 04:36 AM
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.
Bharath Chintala