Forums

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

Execute behavior only when specific field is changed

Nikhil July 1, 2019

Hi,
I have added a behavior for setting default questions in to few fields based on other field value, Ever thing is working fine on create screen but when I click edit on the issue the behavior runs again and it erases the answers entered while creating issue. Now i want to runt this behavior with other condition i.e, it should run only when we edit the field value.

 

I have found similar (https://community.atlassian.com/t5/Jira-questions/Execute-behavior-only-when-specific-field-is-changed/qaq-p/26347) requirement which was answered by Thanos Batagiannis [Adaptavist] But i am unable to render the info from a field and compare it.

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

Script:- 

import com.atlassian.jira.issue.fields.rest.json.beans.IssueRefJsonBean
import groovy.json.JsonBuilder
//-------------------------------------------------------------------------
// This script hides fields and shows them based on the value of a
// single select custom field.
//-------------------------------------------------------------------------
def currentTypeofRequest = getFieldByName("Type of Request").getValue()
def typeOfRequestcf = getFieldByName("Type of Request")
def Summary = getFieldById("summary")
def Description = getFieldById("description")
def fields = [
"None" : [
"summary" : "",
"description" : ""
],
"JIRA Integration" : [
"summary" : "",
"description" : """1. Please provide the name of your JIRA project(s) you wish to integrate with Aha?

2. Please specify if you would like to import, release, epics and stories?

3. Is your project use the standard Tesco JIRA workflow?

4. Is your JIRA project shared with other Product Managers?"""
],
"Access Request / Permission Change" : [
"summary" : "",
"description" : """1. What is your email address?

2. Please specify if you require ‘edit’ or ‘review’ access and for which product

3. What is your job role?

4. Please Provide the product name? """
],
"Ideas Portal" : [
"summary" : "",
"description" : """1.Please provide the product name you wish to add an ideas portal to """
],
"New Product" : [
"summary" : "",
"description" : """1. Please provide the product name?

2. Please provide the name of your line manager.

3. Please provide the email addresses of colleagues who require permissions to create epics, releases and stories.

4. If you require JIRA integration, please specify your project name """

],
"Other Customisation" : [
"summary" : "",
"description" : """1.Please provide an explanation of the customisation you require. E.g. custom report…… ?

2.Please attach any documents that will provide clarity? """
]
]
typeOfRequestcf.setRequired(true)
Summary.setHidden(true)
Description.setHidden(true)

fields."${getFieldByName("Type of Request").getValue()}".each {
if (getFieldByName("Type of Request").getValue() != null) {
typeOfRequestcf.clearError()
field = getFieldById(it.key)
field.setHidden(false)
field.setFormValue(it.value)
} else {
fields."None".each {
field.setFormValue(it.value)
field.clearError()
}
}
}

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

 

Ref:- 

https://community.atlassian.com/t5/Jira-questions/Execute-behavior-only-when-specific-field-is-changed/qaq-p/26347

1 answer

1 vote
Dar Kronenblum
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.
July 1, 2019

Hi @Nikhil  ,

try to add the script to the specific field its depends on and not as initialiser

Nikhil July 3, 2019

Hi @Dar Kronenblum 

I have added it to the specific field itself but the issue is when i click edit screen it shouldn't wipe out the changes i made on create screen until i change the type of request field.

 

Regards,

Pavan

Dayanand
Contributor
October 13, 2022

@Nikhil  

Even i facing same issue on edit screen load custom field value getting reset which i don't want any solution you found

Suggest an answer

Log in or Sign up to answer