- List all request types
- Source code
- More about Groovy in Jira
- Install myGroovy
- Further information
- Support
In the case, an email request in Jira Service Desk relates to its own issue type: „email“. With only one status: „Waiting for support“. An agent clicks a transition like „is a vacation request“. This transition fires a workflow groovy script. As a result, a request is moved from one issue type to another within the same project. Also, the request type is changed from „Email“ to „Vacation“, or whatever request type you want.
List all request types
Open psql, change to database with „\c jira“, for example.
# \d "AO_54307E_VIEWPORTFORM"
Table "public.AO_54307E_VIEWPORTFORM"
Column | Type | Collation | Nullable | Default
----------------+------------------------+-----------+----------+------------------------------------------------------
CALL_TO_ACTION | text | | |
DESCRIPTION | text | | |
FORM_ORDER | integer | | |
ICON | integer | | |
ICON_ID | bigint | | |
ID | integer | | not null | nextval('"AO_54307E_VIEWPORTFORM_ID_seq"'::regclass)
INTRO | text | | |
ISSUE_TYPE_ID | bigint | | not null |
KEY | character varying(255) | | not null |
NAME | character varying(255) | | not null |
VIEWPORT_ID | integer | | |
select * from "AO_54307E_VIEWPORTFORM";
| | 10 | | 10619 | 22 | Zum Beispiel eine neue Maus oder einen Monitor.
| 10301 | neuehardware | Neue Hardware anfordern |
3
What you need is something like <project key>/<request type key“:
it/neuehardware
Sometimes a request type is a hash value:
hr/e5f939ee-6472-4357-b6bd-e1dbfdc9390b
Source code
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.StatusManager
import com.atlassian.jira.config.IssueTypeManager
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
def wfManager = ComponentAccessor.getWorkflowManager()
def statusManager = ComponentAccessor.getComponent(StatusManager.class)
def issueTypeManager = ComponentAccessor.getComponent(IssueTypeManager.class)
def newIssueType = issueTypeManager.getIssueType("10200")
issue.setIssueTypeObject(newIssueType)
wfManager.migrateIssueToWorkflow(
issue,
wfManager.getWorkflow("Vacation"),
statusManager.getStatus("10201")
)
DefaultIssueChangeHolder changeHolder = new DefaultIssueChangeHolder()
// Request Type Custom Field
def serviceType = "customfield_10202"
def customFieldTarget = ComponentAccessor.customFieldManager.getCustomFieldObject(serviceType)
def requestType = customFieldTarget.getCustomFieldType().getSingularObjectFromString("hr/e5f939ee-6472-4357-b6bd-e1dbfdc9390b")
customFieldTarget.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customFieldTarget), requestType), changeHolder)
Install myGroovy
It is free, and an extremely versatile add-on.
https://marketplace.atlassian.com/apps/1218755/mygroovy?hosting=server&tab=overview
Use it together with JSIncluder to inject JavaScript in Jira issues. JSIncluder is from the same group of developers like myGroovy. And it is free, as well.
https://marketplace.atlassian.com/apps/1211670/jsincluder?hosting=server&tab=overview
Further information
https://github.com/mailru/jira-scripts/tree/master/JIRA%20groovy%20templates
https://gist.github.com/chuikoaleksandr
Support
Send me an email for any kind of support related to Atlassian.