Replacing null value with 0 in onCreate method
Options
I'm using some simple java to override the value of an aggregate 'SUM' in the onCreate method:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>//Code for sub-report totals
importPackage(Packages.java.lang);
var lastValue = this.getValue();
reportContext.setPersistentGlobalVariable("tot_workhours", new Float(lastValue));</pre>
<br />
But there are occasions where the field I'm aggregating on will not have any values (e.g. the mechanic didn't work last week), so the summation is null. I've tried different ways to add some testing on the value, but I'm just not getting it. <br />
<br />
Any ideas on how to replace a null value within the code above with a 0 value?
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>//Code for sub-report totals
importPackage(Packages.java.lang);
var lastValue = this.getValue();
reportContext.setPersistentGlobalVariable("tot_workhours", new Float(lastValue));</pre>
<br />
But there are occasions where the field I'm aggregating on will not have any values (e.g. the mechanic didn't work last week), so the summation is null. I've tried different ways to add some testing on the value, but I'm just not getting it. <br />
<br />
Any ideas on how to replace a null value within the code above with a 0 value?
0
Comments
-
What else have you tried? Do you need it to have a 0 value? If it's just for display reasons you can solve that using something like<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if(this.value == null) {
this.value = "0"
}
</pre>Warning No formatter is installed for the format ipb0 -
Yes the value needs to be zero. I used the same statement you referenced and the code looked like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>importPackage(Packages.java.lang);
if(this.value == null) {
this.value = "0"
}
var lastValue = this.getValue();
reportContext.setPersistentGlobalVariable("tot_workhours", new Float(lastValue));</pre>
<br />
But that doesn't appear to work either. I'm wondering if I should test for null values on the field I'm trying to aggregate against so the aggregate function either has a series of values to evaluate or a zero.0 -
FIXED - The solution was using the method I showed above and then testing for NULL data in the denominator of the calculated field. This alleviated the need to do a NULL to zero value conversion on both fields and gave the roll down total to work.
Thanks for everyone's help.0
Categories
- All Categories
- 111 Developer Announcements
- 49 Articles
- 103 General Questions
- 123 IM Services
- 40 OpenText Hackathon
- 31 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 897 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 123 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 1 XM Fax