
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 08:22 AM
Hi,
I have below code its written on BR.
var gr = new GlideRecord("rm_story");
gr.addQuery("parent",current.sys_id);
gr.query();
var TP=0;
var BP=0;
var RP=0;
while (gr.next()) {
TP=TP+ parseFloat(gr.getValue('u_points'));
BP=BP+ parseFloat(gr.getValue('u_burndown_points'));
}
RP=TP-BP;
gs.addInfoMessage(TP + ' ' + BP + ' ' + RP);
=============================================================
"u_points" and "u_burndown_points" fields are decimal by type and I parsed those values as well.
but after executing the code I am getting below values (snap),
What is the reason?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 08:37 AM
decimal fields will still allow NULL values, and since getValue() will return NULL if the field is blank, I believe you can resolve this by modifying your script as follows:
var gr = new GlideRecord("rm_story");
gr.addQuery("parent",current.sys_id);
gr.query();
var TP=0;
var BP=0;
var RP=0;
while (gr.next()) {
if (!gr.u_points.nil()) {
TP=TP+ parseFloat(gr.getValue('u_points'));
}
if (!gr.u_burndown_points.nil()) {
BP=BP+ parseFloat(gr.getValue('u_burndown_points'));
}
}
RP=TP-BP;
gs.addInfoMessage(TP + ' ' + BP + ' ' + RP);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 08:37 AM
decimal fields will still allow NULL values, and since getValue() will return NULL if the field is blank, I believe you can resolve this by modifying your script as follows:
var gr = new GlideRecord("rm_story");
gr.addQuery("parent",current.sys_id);
gr.query();
var TP=0;
var BP=0;
var RP=0;
while (gr.next()) {
if (!gr.u_points.nil()) {
TP=TP+ parseFloat(gr.getValue('u_points'));
}
if (!gr.u_burndown_points.nil()) {
BP=BP+ parseFloat(gr.getValue('u_burndown_points'));
}
}
RP=TP-BP;
gs.addInfoMessage(TP + ' ' + BP + ' ' + RP);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 09:10 AM
Thanks Jon for your quick reply. It worked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 08:51 AM
HI,
Instead of Parse can you use Number.
Thanks,
Ashutosh