Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Script didn't change description

Jamil Rahimov
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.
June 10, 2018

I have one request named as Stamp Request.

1.PNGI want add value from Stamp customfield to description:

2.PNG
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()
}
}

2 answers

1 accepted

0 votes
Answer accepted
Marcos Sanchez
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.
June 11, 2018

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.

Jamil Rahimov
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.
June 11, 2018

It worked.
Thank you very much.

0 votes
Jamil Rahimov
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.
June 10, 2018

script.PNG

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events