You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
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.
Hi @neeta jain
Take a look at this documentation, you will find some good stuff to begin wih
hope this helps
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.