I have one request named as Stamp Request.
I want add value from Stamp customfield to description:
My script works very well it hasn't any error but it doesn't change issue description.
What did I forget?
import com.atlassian.jira.component.ComponentAccessor
//------------------------------------------------------
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueInputParameters
//------------------------------------------------------
def customFieldManager=ComponentAccessor.getCustomFieldManager()//Customfieldleri cagirmaq ucun customfieldManager yaradiriq
def customerRequestType=customFieldManager.getCustomFieldObjectByName("Customer Request Type")//Customer Request Type
Issue issue
def issCRT=issue.getCustomFieldValue(customerRequestType)
if(issue.getIssueType().name=="Stamp Request" && issCRT.toString()=="ad/badc2549-b904-4312-99a6-d7e2b9a0d31f")
{
def stamp=customFieldManager.getCustomFieldObjectByName("Stamp")//Stamp CustomField-ni tapir
def IssStamp=issue.getCustomFieldValue(stamp)//Issuedaki stampin qiymetin tapir
def issueInputParameters=IssueService.newIssueInputParameters()//Parametrler daxil etmek ucun
issueInputParameters.with//Parameter daxil edirik
{
description=description+IssStamp.toString()
}
}
Hi,
You forgot to "save" the issue changes. Furthermore, your code could be optimized.
This code could work for you:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def customFieldManager=ComponentAccessor.getCustomFieldManager()//Customfieldleri cagirmaq ucun customfieldManager yaradiriq
def issueManager = ComponentAccessor.getIssueManager()
def customerRequestType=customFieldManager.getCustomFieldObjectByName("Customer Request Type")//Customer Request Type
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
/*
If you want to set the user that modifies the description, replace the "def user" line with this:
def userManager = ComponentAccessor.getUserManager()
def user = userManager.getUserByName(here goes the username of the user you desire)
Otherwise, it will use the user that is logged in the moment of the execution
*/
def issCRT=issue.getCustomFieldValue(customerRequestType)
if(issue.getIssueType().name=="Stamp Request" && issCRT.toString()=="ad/badc2549-b904-4312-99a6-d7e2b9a0d31f"){
def stamp=customFieldManager.getCustomFieldObjectByName("Stamp")//Stamp CustomField-ni tapir
def IssStamp=issue.getCustomFieldValue(stamp)//Issuedaki stampin qiymetin tapir
issue.description = issue.description+IssStamp.toString()
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}
Hope it helps.
Regards,
Marcos.
It worked.
Thank you very much.
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.
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.