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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So i guess in Behaviours it should be a full proper script, not something simple that able to work in Simple Scripted Validator.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.