Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Calculated custom field to be calculated for just one project

ldogangul September 27, 2018

Hi All,

 

I have a problem as following, any help will be appreciated..

I opened a bunch of calculated custom fields and configure those custom fields like following;

Issue type(s):Global (all issues)

Project(s): Demand

And also hide those custom fields from other projects field configuration scheme's.

 

When I look into logs, I see errors besides from demand project like xxx named project..

One of example: (ASK project for this error)

172.16.1.15 /secure/admin/jira/IndexReIndex.jspa [innovalog.jmcf.fields.CalculatedNumberField] CalculatedNumberField: error evaluating formula of field "Iptal Onayinin Verilme Süresi Gün" of issue ASK-472:
Sourced file: inline evaluation of: `` if (issue.get("resolutiondate") == null) return null; return ((Double)(issue. . . . '' : at Line: 3 : in file: inline evaluation of: `` if (issue.get("resolutiondate") == null) return null; return ((Double)(issue. . . . '' : .getTime ( )

Target exception: java.lang.NullPointerException: Attempt to invoke method getTime on null value

Navigate to the following URL to edit the formula: htt/secure/admin/EditCustomField!default.jspa?id=12521

I want to eliminate those errors. What should  I do ? Regards, Levent..

2 answers

0 votes
David Fischer
Community Champion
September 27, 2018

Are you using JMCF 1.7.2? Because with that version, calculated fields should not evaluate the formula for issues that don't match any configured context for the field.

In any case, you should also test customfield_12519 for null values before calling .getTime() on its value.

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2018

You need to amend the script so that it does not try to run if the resolution date field is empty.

If you can share the script with us, we can probably help you correct it.

ldogangul September 27, 2018

Hi Nic,

I am already doing it. My code is below:

<!-- @@Formula:
if (issue.get("resolutiondate") == null) return null;
return ((Double)(issue.get("resolutiondate").getTime() - issue.get("customfield_12519").getTime())) / 1000 / 3600 / 24 -->

ldogangul September 27, 2018

The formula does not give an error.

The error is: The customfield is trying to calculate this in other projects which is inconvenient. I need to avoid calculating for other projects besides from my Demand Project..

Any ideas ??

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2018

The formula won't give you an error itself, as the code looks ok.  But I suspect the issue.get in line 1 is failing, not returning a null, and hence it never evaluates it and then moves on to the next line where it promptly fails as well.

If you don't want it to run in certain projects, change the scripted field context so that it only exists in the projects you need it in.

Suggest an answer

Log in or Sign up to answer