Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,554
Community Members
 
Community Events
185
Community Groups

Why is behaviour running when form value hasn't changed.

I have behavior that is attached to a custom field (Client Type).  If the Client Type changes, I need to reset another custom field (State) to None so that the user has to pick it again.

This works fine while making changes to different fields on the form, but the behavior also runs when I submit the Create form and wipes out the other custom field so the form throws an error because the 2nd custom field is required and has been reset to None.

The value of the Client Type field did not change but the code is still running.  I have verified the through logging.

import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Level

log.debug("Running Client Type field code")

def ClientTypeField = getFieldById(getFieldChanged())
def selectedClientType = ClientTypeField.getValue().toString()
log.debug("Client Type = " + selectedClientType)

def stateField = getFieldByName("State")
stateField.setFormValue(null)

 

Why is the behavior running when I submit the form???

2 answers

0 votes
Jia Jie
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.
Mar 03, 2021

Hi Margaret,

It's possible caused by this bug here: Field server-side behaviour scripts trigger when create/edit window opened before the user has interacted with the field

When you submit the form and an error message is thrown, it reload the screen and the field server-side behaviour scripts triggered before/without interacting with the field.

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 16, 2021

That is not my experience...

What I normally see is that the script runs once when you open the screen (be that for create, edit or any transition) and the form is initialized with its starting value. FOr create that could be "null" or the default value for the context. For edit/transition, that would be with the value coming from the issue object in the back-end.

Then, it executes only when you change the value.

I've never seen it executing when submitting the form.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events