It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Avoid duplication of label field value Edited

Team,

We have a requirement like..while creating or updating issue users are providing the values and that values should not be duplicated.

For example: let say there is a label type field and already that field has TEST value for an issue and while creating/updating new issue a user should not add TEST value.

Any suggestions will be appreciated.

Note: It's not like only for Label type field if you have any idea or suggestion to achieve this then also welcome. The main purpose is ..user should be able to add multiple values to that field and the values should not be duplicate.

2 answers

0 votes
Ismael_Jimoh Community Leader Oct 22, 2019

Hi Yogesh,

Other than restricting who can create labels using scriptrunner behavior plugin or using the component field, there is no way to prevent people from creating other labels that do not match the one you already have.

 I will lean more towards the component field because it is clear that the project admin is the only person who can add component.

Cheers

Hi @Ismael_Jimoh 

Thanks for your response.

What im thinking is ..we can do it using a script validator where we can fetch all the values of the field and then check whether the new field value is equal to existing value or not.

if so, then we should throw an error called this value already exist.

What do you think?

Ismael_Jimoh Community Leader Oct 23, 2019

This could be possible but then resource intensive as you will either need to do this from a cron service, or by event listener which means issue update event that I cannot recommend.

This also does not scale because if a label has already been used, how does the script determine which to delete and depending on how many issues you have and how many labels per issue it could mean an issue update takes multiple minutes to be completed.

Hence, though this is possible, I cannot recommend it. Instead as suggested earlier constrain available Labels to those someone created and other users can then select from this when they type.

Hi @Ismael_Jimoh , Yeah I understood but here the problem is we are using a multiline text field where users need to enter the alphanumeric character which is generated in SAP while creating/updating issue manually, so sometimes users are adding same alphanumeric character which is already added by someone on issue.

So my team manager wants that the user should not add the same value.

How we can restrict this.

Ismael_Jimoh Community Leader Oct 23, 2019

@Yogesh_Mude 

Are you using the standard label field or a text field as your last comment has me confused. 

Yeah I understood but here the problem is we are using a multiline text field

Do clarify this.

Cheers.

HI @Ismael_Jimoh 

Actually, while implementation we used multiline text field but while adding data to this text field users are entering semicolon, comma, colon (: , ;) for value separation and also adding duplicate values to avoid the value separator I thought like we should go for label type custom field so that user don't need to add separator here...so with this label type cust field now i want to avoid value duplication.

Hole it clear. 

HI @Ismael_Jimoh 

have you get a chance to look at it.

See if you can help me out with this.

Ismael_Jimoh Community Leader Oct 30, 2019

Hi @Yogesh_Mude 

Do the following:

  1. Go to Behaviours page (<baseurl>/secure/admin/Behaviours!default.jspa)
  2. Create a new behaviour
  3. Click Fields
    Screenshot 2019-10-30 at 12.55.20.png
  4. In the add field section, search for the field you want to restrict
  5. Click the Readonly/Writable option(second option)
    Screenshot 2019-10-30 at 12.56.59.png
  6. Click Add new condition (select Except in the radio button)
  7. Specify group or role that can edit the field.
  8. Add a Mapping to ensure it is restricted only within a context you want.
  9. Save the changes

Your final solution should look like:

Screenshot 2019-10-30 at 13.16.38.png

When user attempt to add values to the label, it will bring up the edit screen and the field will be locked to them still.

Cheers.

Hi Yogesh,

Did you find any solution for this as we are also having the same requirement where we want to restrict the user from creating the ticket with the existing value in an alphanumeric field?

Thanks,

Eshwar.

Yes, using the script we did it.

First, you need to fetch the values of the label field and see if the user is entering the same values which are already contained. if so, then set the error saying XXX values already exist or contain with XXX issue key. if not, then allow the user to add it.

Is it possible to do this on the Customer Portal?

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you