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,367,325
Community Members
 
Community Events
168
Community Groups

Validator to restrict the Reporter in creating the same request again

Hello Team,

I need to restrict the reporter in creating the same request (Ex: Request for a New Laptop) till the existing ticket is Closed/Cancelled.

 

Hosting Type: Data Center

We use plug-ins like Script Runner, JSU, JMWE.

 

Please suggest a way to achieve this.

 

Thanks in advance!

 

2 answers

1 accepted

1 vote
Answer accepted

Hi @Sriharsha 

what do you mean by "same request"? Do you mean an existing, open request (issue) of the same customer request type? Or any issue in the same project with the same Summary?

Assuming you mean the same request type, you can add a Scripted (Groovy) Validator with a script like:

jqlSearch( "project=${issue.projectkey} and \"Customer Request Type\" = \"${issue.get("Customer Request Type")?.name}\" and status not in (Closed,Cancelled)", 1).size() == 0

Hi @David Fischer _Appfire_ ,

Thank you for the quick response!

Yes, you are correct. What I meant is an existing, open request of the same request type. 

And, also we need to take care of the Custom Field - "Hardware Item " which is a select list (single choice) of the same request type.

Ex - Laptop, Desktop, etc.

If an 'X' reporter raised a request with Hardware Item Called "Laptop" and the issue is still open. At this point of time, the same reporter 'X' cannot create a new request with same Hardware item called "Laptop".

Hope I'm clear.

Regards,

Sriharsha

Hi @Sriharsha ,

you can add that condition in your JQL expression:

jqlSearch( "project=${issue.projectkey} and \"Customer Request Type\" = \"${issue.get("Customer Request Type")?.name}\" and status not in (Closed,Cancelled) and \"Hardware Item\" = \"${issue.getAsString("Hardware Item"}\"", 1).size() == 0

Thank you, David!

You're welcome @Sriharsha 

Can you "Accept" the answer so that it can benefit our Community members?

1 vote
Alex Koxaras Community Leader Aug 16, 2022

Hi @Sriharsha 

On the "on create" transition of your issue type you have to add a validator to check of any issuetype of the same request type of the same reporter exists. If that happens, then a message will appear on the customer (reporter). Of course you have to make sure that the check you perform is indeed the one you need and that it will not yield an error.

Alex 

Hi @Alex Koxaras , thank you for quick response!

Can you pls elaborate? 

 

Thank you!

Alex Koxaras Community Leader Aug 16, 2022
  • Edit the workflow of your issuetype to which this request type is associated with.
  • Click the "diagram" and click the "on create" transition
  • On the popup to your right click validators
  • Click Add validator
  • Search and click for any groovy script of your liking (e.g. Scripted (Groovy) Validator (JMWE app))
  • Write your script validation (similar to this): issue.get("customfield_11151")?.name == "Get IT help" && issue.get("reporter")?.name == currentUser
  • Test your validation to see if it yields proper results
  • Write the error message which will appear to the user
  • Save the validator
  • Publish your workflow

groovy validator.png

Thank you so much, Alex!

 

Will keep you updated!

 

Regards,

Sriharsha

Like Alex Koxaras likes this
Alex Koxaras Community Leader Aug 16, 2022

@Sriharsha I would do what @David Fischer _Appfire_ said. It is the right way :)

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events