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,558,927
Community Members
 
Community Events
184
Community Groups

Restrict issue creation with certain symbols

Edited

Hi.

I want to restrict creation of issues from portal with certain symbols in Summary and Description.

I can put Simple Scripted Validator on workflow creation with

!issue.summary.value.contains("«") && !issue.summary.value.contains("»")

and it works, but how do i use this restriction only for portal request issues creation?

Or please advise how can i use this in Behaviours?

3 answers

1 accepted

0 votes
Answer accepted

import com.atlassian.jira.component.ComponentAccessor

def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Customer Request Type")
def requestType = issue.getCustomFieldValue(cf)

if ((requestType.toString() == "sdp/96990dda-e6ce-4edb-8df3-29d6bfdf5984") && (issue.description.value.contains("«") || issue.description.value.contains("»") || issue.summary.value.contains("«") || issue.summary.value.contains("»"))) {
return false
}
else {
return true
}

 

To find the requestType string get an issue that has the Request Type that you want to find the id for and:

import com.atlassian.jira.component.ComponentAccessor

def issue = ComponentAccessor.issueManager.getIssueByCurrentKey("Issue Key")
def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Customer Request Type")
issue.getCustomFieldValue(cf)

Hi @Phil Evans ,

It could be possible to apply the restriction to only portal requests by creating an IF condition that will check if the Request Type field value is not null (All Portal Request Issues would need value in this field). Check out this Community Discussion for some ideas on how the Script to get the Request Type values would look like: Get possible values for Customer Request Type via script runner in Service Desk > v3.3

I hope this helps.

 

Kind regards,
Irfan

Hi Ifran.

In Behaviours i can map strictly to the service desk or portal request I want script to work on, but i had no success with the script itself yet.

its Irfan, excuse me, @Irfan Mazuki 

I am a bit of a newbie with groovy.

This line

!issue.summary.value.contains("«") && !issue.summary.value.contains("»")

does work in Simple Scripted Validator, but it is not recognized when used in Behaviours, and im still grasping why.

So i guess in Behaviours it should be a full proper script, not something simple that able to work in Simple Scripted Validator.

no success yet

Hey Phil, (Thanks for the name correction)

Yes, you're right. Validator is a Workflow function that is triggered when Transitioning Issues, hence the Issue objects are already in place. Behavior needs to be mapped to Issue Types and Projects on a Global-level (Jira instance), so the Issue object is not present yet.

With your requirement, I'd say Validator is the way to go. You can create a script where on top of the condition you have created, it will also check if the Issue has any Request Type value set, to determine if it's a request/issue created from the Portal.

Thank you, Irfan.
Gonna go with Validator way.

Came up with this but doesnt seem to work with specific request:

 

import com.atlassian.jira.component.ComponentAccessor

def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Customer Request Type")
def requestType = issue.getCustomFieldValue(cf)

if ((requestType == "sdp/96990dda-e6ce-4edb-8df3-29d6bfdf5984") && (issue.description.value.contains("«") || issue.description.value.contains("»") || !issue.summary.value.contains("«") || !issue.summary.value.contains("»"))) {
return false
}
else {
return true
}

ok got some NOTs there which shouldnt be there

still doesnt work

import com.atlassian.jira.component.ComponentAccessor

def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Customer Request Type")
def requestType = issue.getCustomFieldValue(cf)

if ((requestType == "sdp/96990dda-e6ce-4edb-8df3-29d6bfdf5984") && (issue.description.value.contains("«") || issue.description.value.contains("»") || issue.summary.value.contains("«") || issue.summary.value.contains("»"))) {
return false
}
else {
return true
}

ok I think I got it, testing

@Irfan Mazuki thank you for guidance.

Hey @Phil Evans , great to see you got it working! Thanks for sharing the solution on this post, it'll definitely be helpful to other users facing a similar situation :)

Like Phil Evans likes this

@Nic Brough -Adaptavist- can you help please?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events