Hi,
I saw few threads about this topic, but all were related to old Customer Request Type values e.g. it/request-type. In JIRA 7.11 I have new values e.g. project/UUID. I'm trying to create issues with groovy (Insight if that makes a difference). My code looks something like this:
IssueService issueService = ComponentAccessor.getIssueService()
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters
.setProjectId( issue.getProjectObject().getId() )
.setSummary( "Odebranie uprawnień" )
.setIssueTypeId(issue.issueTypeId)
.setPriorityId(issue.priority.id)
.setReporterId(issue.reporterId)
.addCustomFieldValue("customfield_10802", "isd/bba760da-e62d-4da3-b719-d688beecc9ac")
I have also tried:
1. SD Automation - fires too late for my other post functions
2. Power Scripts - can set CRT in later transitions, but on Create throws error with key not existing (probably launches before link creation).
3. Same script in Script Runner also doesn't set CRT
I have found a reason. Script Runner (customer has version 5.4.12 and JIRA 7.11.2) doesn't set custom fields which are not on a Create screen. issueManager.updateIssue is not needed in this case. Probably post function Creates issue originally does the job.
Is this the full code snippet?
The CustomField may have the right value but you need to update the issue. I use IssueManager for that
issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue, EventDispatchOption.ISSUE_UPDATED, false)
You can get the issue by grabbing the newly created issue as a return from the creation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry for late reply, I was on a vacation.
Here is some longer excerpt:
IssueService issueService = ComponentAccessor.getIssueService()
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters
.setProjectId( issue.getProjectObject().getId() )
.setSummary( "Odebranie uprawnień" )
.setIssueTypeId(issue.issueTypeId)
.setPriorityId(issue.priority.id)
.setReporterId(issue.reporterId)
.addCustomFieldValue("customfield_15732", it.getObjectKey())
.addCustomFieldValue("customfield_11901", stanowiskoValue)
.addCustomFieldValue("customfield_12100", jednostkaOrgValue as String)
.addCustomFieldValue("customfield_11304", nazwaKomOrgValue)
.addCustomFieldValue("customfield_15503", uzasadnienieValue)
.addCustomFieldValue("customfield_15245", zgloszenieDlaValue)
.addCustomFieldValue("customfield_10802", "isd/bba760da-e62d-4da3-b719-d688beecc9ac")
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueService.CreateValidationResult createValidationResult = issueService.validateCreate(user, issueInputParameters)
if (createValidationResult.isValid())
{
IssueService.IssueResult createResult = issueService.create(user, createValidationResult)
IssueManager issueManager = ComponentAccessor.getIssueManager();
issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), createResult.issue, EventDispatchOption.ISSUE_UPDATED, false)
}
I'm creating tasks in a loop. Other custom fields are being set. I have added updateIssue, but it didn't help. There are no errors in logs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry for late reply, I was on a vacation.
Here is a longer excerpt from my script:
IssueService issueService = ComponentAccessor.getIssueService()
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters
.setProjectId( issue.getProjectObject().getId() )
.setSummary( "Odebranie uprawnień" )
.setIssueTypeId(issue.issueTypeId)
.setPriorityId(issue.priority.id)
.setReporterId(issue.reporterId)
.addCustomFieldValue("customfield_15732", it.getObjectKey())
.addCustomFieldValue("customfield_11901", stanowiskoValue)
.addCustomFieldValue("customfield_12100", jednostkaOrgValue as String)
.addCustomFieldValue("customfield_11304", nazwaKomOrgValue)
.addCustomFieldValue("customfield_15503", uzasadnienieValue)
.addCustomFieldValue("customfield_15245", zgloszenieDlaValue)
.addCustomFieldValue("customfield_10802", "isd/bba760da-e62d-4da3-b719-d688beecc9ac")
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueService.CreateValidationResult createValidationResult = issueService.validateCreate(user, issueInputParameters)
//log.warn "Mario przed createValidationResult"
if (createValidationResult.isValid())
{
//log.warn("Mario tworzenie zgłoszeń OK")
IssueService.IssueResult createResult = issueService.create(user, createValidationResult)
IssueManager issueManager = ComponentAccessor.getIssueManager();
issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), createResult.issue, EventDispatchOption.ISSUE_UPDATED, false)
}
I'm creating tasks in a loop. I have added updateIssue as you suggested, but it didn't help. There are no errors in logs. Other custom fields are being set.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.