Hi Team,
I have implemented a script for calculating Number Of Weeks:
import com.atlassian.jira.component.ComponentAccessor
def dateFieldObject = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName("Start Date")[0]
def dateFieldObject2 = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName("End Date")[0]
def dateValue= issue.getCustomFieldValue(dateFieldObject) as Date
def dateValue2= issue.getCustomFieldValue(dateFieldObject2) as Date
def now = new Date()
def diffdate
// if "End Date" is reached or exceeded, which means "now" is later than "End Date"
if (now.after(dateValue2)){
// End Date - Start Date
diffdate = dateValue2 - dateValue
} else { // if now is before or equal to "End Date"
// End Date - now
diffdate = dateValue2 - now
}
if (diffdate) {
double noofweeks = diffdate/7
double roundNoOfWeeks = Math.round(noofweeks)
int value = (int) roundNoOfWeeks;
return value
}
but getting attached error, please kindly check and give me some solution where I am doing wrong.
The error message says line 6 is failing. I think the code on that line is the one trying to get a date from the "start date" field. A null pointer error here means that there is no data in something you are passing into a method on that line.
Either the field does not exist for this issue, or the data in it is not a date, or is empty.
Hi @neeta jain
Take a look at this documentation, you will find some good stuff to begin wih
hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.