Forums

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

How to make value persist on Edit Screen after issue Created

Kamal Iqlaas Ismail November 5, 2021

Hi everyone,

Hope this question finds you well.

I have set up a behaviour script in Create screen, which when a user selected a custom field, the system field will show the predetermined value which have been set.

For example, when i chose A in the custom field, the system field will show B value.

If i chose the system field value manually, the issue will be created with the manual value. This is intended as well.

However, after the issue gets created, when I click the Edit button on the View issue screen, the system field value is showing the predetermined value as per script.

How to persist the system field value in the Edit screen?

And if the user decides to change the custom field value on the Edit screen, the system field value should behave as per script that have been set. 

Should more info needed, please let me know.

Here is the current script that I wrote in ScriptEditor:

def maps = 

[

"hello": ["1", "2", "3"],

"goodbye": ["4", "5", "6"]

]

void setSystemFieldValue(){

FormField ffSystemField = getFieldByName("System ")

FormField ff_CustomField = getFieldById(customfield_id)

String CustomFieldValue = ff_CustomField.getFormValue()

// This if/else will persists the value that gets created in Edit screen
// Start
if (!ffSystemField.getFormValue()){

ffSystemField.getFormValue()

}
// End

// This if/else will set the system field value when choosing the custom field value

if (CustomFieldValue in maps){

ffSystemField.setFormValue(maps[CustomFieldValue])

} else {

ffSystemField.setFormValue("-1")

}

}

Any pointers is greatly appreciated!

1 answer

0 votes
PD Sheehan
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.
November 9, 2021

I think you'll find (if you search or view the value via rest that the correct value was persisted, however, when you edit, the behaviour fires again when the form fields are populated by jira.

So you need to suppress the behaviour in those conditions:

Wrap all the content of your method inside

void setSystemFieldValue(){
if(!underlyingIssue){
//your code here
}
}

You can also try to use the "getActionName()" built-in method and check if getActionName() != "Create" but I don't like this as much.

Suggest an answer

Log in or Sign up to answer