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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

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)

@Nic Brough _Adaptavist_ can you help please?

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 Mazli 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 Mazli 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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Announcing Team Calendars in Confluence Data Center

Hi Community! We're thrilled to share that Team Calendars for Confluence is now a built-in feature for Confluence Data Center releases 7.11 and beyond.  A long time favorite,  Team Cale...

59 views 0 3
Read article

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