Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object issue while using export all fields to excel/xml

Vijay Sv December 22, 2015

I am using Export (All fields) function to pull all the scripted custom fields, but logs are getting filled up with below error.


org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'DocumentIssueImpl[issueKey=CDN-5922]' with class 'com.atlassian.jira.issue.DocumentIssueImpl' to class 'com.atlassian.jira.issue.MutableIssue'
at Script57.run(Script57.groovy:17)
2015-12-21 12:36:21,397 http-bio-443-exec-21508 ERROR I850693 755x2988073x14 1iysghl 10.162.5.196 /sr/jira.issueviews:searchrequest-excel-all-fields/temp/SearchRequest.xls [onresolve.scriptrunner.customfield.GroovyCustomField] *************************************************************************************
2015-12-21 12:36:21,397 http-bio-443-exec-21508 ERROR I850693 755x2988073x14 1iysghl 10.162.5.196 /sr/jira.issueviews:searchrequest-excel-all-fields/temp/SearchRequest.xls [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: CDN-5922, field: Deployed in Name
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'DocumentIssueImpl[issueKey=CDN-5922]' with class 'com.atlassian.jira.issue.DocumentIssueImpl' to class 'com.atlassian.jira.issue.MutableIssue'
at Script21.run(Script21.groovy:13)
2015-12-21 12:36:21,412 http-bio-443-exec-21508 ERROR I850693 755x2988073x14 1iysghl 10.162.5.196 /sr/jira.issueviews:searchrequest-excel-all-fields/temp/SearchRequest.xls [onresolve.scriptrunner.customfield.GroovyCustomField] *************************************************************************************
2015-12-21 12:36:21,412 http-bio-443-exec-21508 ERROR I850693 755x2988073x14 1iysghl 10.162.5.196 /sr/jira.issueviews:searchrequest-excel-all-fields/temp/SearchRequest.xls [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: CDN-5922, field: Customer Commit Date
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'DocumentIssueImpl[issueKey=CDN-5922]' with class 'com.atlassian.jira.issue.DocumentIssueImpl' to class 'com.atlassian.jira.issue.MutableIssue'
at Script39.run(Script39.groovy:17)
2015-12-21 12:36:21,662 Sending mailitem com.atlassian.jira.mail.IssueMailQueueItem@33976e00[issue=com.atlassian.jira.issue.IssueImpl@55646aac[id=267772,summary=Beta FPC: Searching / follow up for new issues,key=HOA-55030,created=2015-11-19 14:59:02.507,updated=2015-12-21 12:32:10.167,assignee=C5221998:10102,reporter=C5221998:10102],remoteUser=C5221998:10102,notificationType=All_Watchers,eventTypeId=6,templateId=6] INFO ServiceRunner Mail Queue Service [renderer.wiki.links.JiraIssueLink] Unable to resolve an issue with key: HOA-55031
2015-12-21 12:36:22,426 http-bio-443-exec-21508 ERROR I850693 755x2988073x14 1iysghl 10.162.5.196 /sr/jira.issueviews:searchrequest-excel-all-fields/temp/SearchRequest.xls [onresolve.scriptrunner.customfield.GroovyCustomField] *************************************************************************************

Please let me what has to be done in this scenarios.

------------------------------------------------------------------------------------------------------------------------

Example scripted Custom Field:

-----------------------------------------------------------------------------------------------------------------------

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue


ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
String displayContent = "";
MutableIssue myIssue = issue;
def versions = myIssue.getFixVersions();

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Vijay Sv December 23, 2015

I got the solution for this i was using an issue object that is a document type class as an issue directly, need to convert from the issue document to an issue in this scenario.


 

0 votes
Vasiliy Zverev
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.
December 22, 2015
  1. Do you need to use Mutableissue instead Issue. It is requared if you want to update in issue. Here you need just to get some values
  2. When you get custom field value for date you get  java.sql.Timestamp. object. You can have troubles to cust it to stirng here: commitValue!="". If you want to checj wether this field is empty you should use commitValue.getTime() != 0;
  3. To speed up development see this: https://answers.atlassian.com/questions/32982259.

 

Vijay Sv December 22, 2015

Thanks Vasiliy!! I am able to update in issue. Here the issue is, for example if the custom field "Deployed in Name" is part of Project "A" and issue Type "Task" & "Defect"(Screens) and for Project "B" it is part of only issuetype "Task(screen)" not "Defect(screen)". in such scenarios if i try to export my query using "Export(All fields)" function it fails to cast that object in defect(screen) because custom field is used only task(screen) of project "B". how do we ignore such cases? changing Global configurations for Issuetype & project works for other custom fields but couple of custom fields are shared with lot of projects and it is really difficult to change at the configuration level. is there any way we can ignore this through Script that i am using?

TAGS
AUG Leaders

Atlassian Community Events