Hi Community, I have a problem regarding with the datetime field . I am using two datetime custom field. I also use this scripted field by scriptrunner, but it returns an error
I used Date Time Range Picker as a Searcher and a Custom Template :
$datePickerFormatter.withStyle($dateTimeStyle.DATE).format($value)
code:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import java.util.Date.*
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def dateFieldObject= customFieldManager.getCustomFieldObject('customfield_10806');
def dateFieldObject2= customFieldManager.getCustomFieldObject('customfield_10807');
if(issue.getCustomFieldValue(dateFieldObject) && issue.getCustomFieldValue(dateFieldObject2)) {
def dateValue= issue.getCustomFieldValue(dateFieldObject) as Date
def dateValue2= issue.getCustomFieldValue(dateFieldObject2) as Date
return dateValue - dateValue2
}
it says cannot return value of type int on method for java.util.Date. Thanks
Hello,
Your code returns the difference as days between two date fields. When you run the code it returns an integer. However your script field uses date time as a searcher. That's why your code cannot cast this number to your script field. If you change your script field's searcher to free text searcher or number searcher and template to text field or number field it should work just fine.
Regards,
Elifcan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.