Forums

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

Could some one please suggest how we can have a validation on EDIT screen using behaviour plugin ?

shrikant maheshwari March 24, 2022

Hi All,

I have tried using behaviour and putting my script in the Initialiser and in the server script as well for the corresponding field but the validation does not seems to work.

 

Requirement -

Based on the Issue type I need to make a custom field mandatory while creating the issue --- Already done 

But at the time of Editing the issue and changing the Issue type the corresponding field does not become mandatory or non mandatory on the basis of issue type?

2 answers

0 votes
shrikant maheshwari March 24, 2022

Hi Fabio,

 

I have written the same script in both the places already.

But at the time of Editing the Issue if I change the issue type say from task to Bug then the corresponding "Root cause" field does not become mandatory and vice-versa. Please could you go through the script and let me know the changes .

 

 

 

Screenshot 2022-03-24 at 11.40.45.png

0 votes
Fabio Racobaldo _Herzum_
Community Champion
March 24, 2022

Hi @shrikant maheshwari ,

Initializer works when you open the edit/create screen.

If you want that your code works when change a specific field you need to add the same script also for that field. In your scenario, you need to put the same code at Issue Type field level

Immagine.png

It should fix you issue.

Ciao,

Fabio

Fabio Racobaldo _Herzum_
Community Champion
March 24, 2022

Hi @shrikant maheshwari ,

if you need to make field mandatory based on issue type, the best pratice says to use Field Configuration Scheme based on issue type.

Btw, your code should work, I jest tested it in my local environment.

Please could you share the mapping for your behaviour?

shrikant maheshwari March 24, 2022

Hi Fabio,

please find the mapping screen shot and the problem is when i am trying to edit an existing Issue and then changing the Issue type to "BUG" then Root cause field is not becoming mandatory its still non mandatory.

 

Screenshot 2022-03-24 at 12.53.33.png

Fabio Racobaldo _Herzum_
Community Champion
March 24, 2022

Hi @shrikant maheshwari ,

that is the problem. You behaviour currently works just for bug. If you need to work for all issue types (mandatory field should depends form all issue types) you need to edit mapping so that it works at project level and for all issue types.

It should fix your issue.

Fabio

shrikant maheshwari March 24, 2022

Hi Fabio,

I have already tried that but it does not works, please find the attached screens shots.

 Please see the screen shot 2 and 3 , so my original issue was TASK and when i clicked on EDIT and changed the Issue type to BUG still the field root cause is not mandatory.

Also using field configuration scheme based on Issue type will not work as I have to use the validation in both create and Edit screen.

If i try using different field configuration based on Issue type then at the time of Editing the issue suppose a task and then changing the Issue type to BUG it will still show the field configuration for Task only as the Field Configuration is set on the basis of Issue type and not on EDIT issue.

Screenshot 2022-03-24 at 13.11.04.pngScreenshot 2022-03-24 at 13.12.41.pngScreenshot 2022-03-24 at 13.13.04.png

Fabio Racobaldo _Herzum_
Community Champion
March 24, 2022

In my local environment it works like a charm. Please verify that your cf id is correct.

If you selected all issue types as mapping and put your code in Initializer and Issue Type, it should work.

Immagine.png

shrikant maheshwari March 24, 2022

@Fabio Racobaldo _Herzum_ 

Does this work when you have an already existing issue and then you edit the issue and change the issue type to "Task" and then the description field becomes mandatory and vice versa.

Fabio Racobaldo _Herzum_
Community Champion
March 24, 2022

 @shrikant maheshwari , if you need to setup mandatory fields at creation time please use field configuration. Through the scheme you can define a spefic field configuration for each your issue type. It is a standard approach.

shrikant maheshwari March 24, 2022

but what about at the time of EDIT ?

Fabio Racobaldo _Herzum_
Community Champion
March 24, 2022

At the edit time field mandatory on creation will remain as mandatory.

Btw, my behaviour works on both creation and edit.

shrikant maheshwari March 24, 2022

In my case, its working fine at the time of creation but when I edit and change the issue type the field does not become mandatory ?

shrikant maheshwari March 24, 2022

no please try editing another issue type then task and then change issue type from say bug to task and then see does that field becomes mandatory or is it still non mandatory ?

shrikant maheshwari March 24, 2022

Do I have to reset the field as the field remains the same in correspondance to the old ISSUE type and does not change even after editing the issue type

Suggest an answer

Log in or Sign up to answer