- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 02:38 AM
Script query return 3 numeric value for one record size value
Requirement is that , we need to calculate (add) all these and update the total through BR
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 06:06 AM
hi @sukran
Please try the below code its working for me i have tried the same in PDI .
Please try to run it in background first.
Thank you!
Vishakha Yadav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 06:10 AM
Thanks ,. this information helps and now i understand what you are struggling with.
Here is a script that will work
var totalSize = 0;
var gr = new GlideRecord("cmdb_ci_disk");
gr.addEncodedQuery("computer=5f9b83bfc0a8010e005a2b3212c9dc07"); //use sys_id of computer you want to add
gr.query();
while (gr.next()) {
gs.print(gr.size);
var s = parseFloat(gr.size.toString().replace(/GB/g, ""));
totalSize = totalSize + s
}
gs.print(totalSize);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 02:46 AM
Hi,
Please check below link,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 02:52 AM
HI,
With the information provided.
Assuming your values are in 3 variables , b c & d
b = parseInt(b);
c = parseInt(c);
d = parseInt(d);
var a = b + c + d
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 03:41 AM
its not 3 different variables
After queries table for computer table storage volume disk .. its return 3 values
we need total count to set value one custom field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 03:49 AM
AS i mentioned before , its hard to understand so please add more information, what is the table, what field.
how is one field giving you 3 values?
What is the trigger.