Addition of two different values from two tables
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 12:54 AM
I have scenario like i have three different tables. Every table have same column name and it is "value" and it consists of values.
one table have value as '6'
second table have value of '8'
third table have value of '9'
NOW i want to add those values like 6+8+9 and output will come as 23. Now i want to paste this output in another table which have a column as total.
can any one suggest me how to write business rule for this
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 01:04 AM
Hi @RERA02 ,
Create a business rule on table 4 depends on your condition.
var total = 0;
var table1 = new GlideRecord('table1');
table1.addQuery('serial_number', '12345');//take unique field on 3 tables store serial number
table1.query();
while (table1.next()) {
total += parseInt(table1.value);
}
var table2 = new GlideRecord('table2');
table2.addQuery('serial_number', '12345');
table2.query();
while (table2.next()) {
total += parseInt(table2.value);
}
var table3 = new GlideRecord('table3');
table3.addQuery('serial_number', '12345');
table3.query();
while (table3.next()) {
total += parseInt(table3.value);
}
current.4rthtablefieldtosetvalue=total;
Please mark it as solution proposed and helpful if it serves your purpose.
Thanks,
Anand