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!
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.
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.