Hi,
it is possible to set the "Customer Request Type" Custom Field in groovy?
My first try result: "java.lang.String cannot be cast to com.atlassian.servicedesk.internal.customfields.origin.VpOrigin"
Is there any way?
Thanks!
Community moderators have prevented the ability to post new answers.
I found a solution for me:
... requestTypeCF.getCustomFieldType().getSingularObjectFromString("STRING") ...
I want to set the request participants but don't know the internal custom field type. Seems you have done some scripting with service desk custom fields. Any tips you can pass along?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Timothy,
The snippet provided by Benjaminis the one you need to fetch the options that you want to set in your script.
I included an example script that will fill in the JIRA Service Desk Request Type based on the IssueType:
import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.issue.ModifiedValue import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import com.atlassian.jira.issue.util.IssueChangeHolder // Remove these lines if you want to run this script as a post function script import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.IssueManager Issue issue = ComponentAccessor.getIssueManager().getIssueObject("MYISSUENUMBER-123") // Change this to the ID of your Customer Request Type custom field (added by JIRA Service Desk) final String SERVICE_DESK_REQUEST_CUSTOMFIELD = "customfield_11800" // These are the possible values for this specific Service Desk instance - you can check those in your instance by consulting the REST view of an issue: // http://JIRASERVER/rest/api/2/issue/ISSUENUMBER?expand=renderedFields,editmeta // In this list you can find the value next to "customfield_11800" (id of the field) final String INCIDENT_REPORT = "support/incident-report" final String SERVICE_REQUEST = "support/service-request" CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager() CustomField requestTypeField = customFieldManager.getCustomFieldObject(SERVICE_DESK_REQUEST_CUSTOMFIELD) String issueType = issue.getIssueTypeObject().getName(); String requestTypeValue = null; switch (issueType.toLowerCase()) { case "incident": requestTypeValue = INCIDENT_REPORT; break; case "service request": requestTypeValue = SERVICE_REQUEST; break; default: break; } if (requestTypeValue != null) { IssueChangeHolder changeHolder = new DefaultIssueChangeHolder(); def requestType = requestTypeField.getCustomFieldType().getSingularObjectFromString(requestTypeValue) requestTypeField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(requestTypeField), requestType), changeHolder) }
Kind regards,
Tom
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This code works like a charm.
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.
When I tried this line of code:
requestTypeField.getCustomFieldType().getSingularObjectFromString("sd/system-access")
In my mind played sweetest symphony. Tom, you are the man!
Additional explanation
The "sd/system-access" is the string which consists of:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Seems like this isn't working for JSD 3.3 anymore?
€: for me, the id was "56973cbb-745f-4d2c-97ea-5bd7a54fd2ae", not a normal string
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Christian Pascher I am using JSD 3.3 and this didn't work. The id looks in fact as a "random" String...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is an open issue to solve the key creation inconsistency: https://jira.atlassian.com/browse/JSD-4916
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is this valid in recent version? I don't get the value of the request type which in this example is set to
support/incident-report
Where can I find it? And what is the right one?
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.
With recent Service Desk version, "Customer Request Type" value consists in a `project/UUID` string which can be found in database table AO_54307E_VIEWPORTFORM (key) in relation with AO_54307E_VIEWPORT (key).
Refer to SQL query available at https://community.atlassian.com/t5/Jira-Service-Desk-questions/Re-set-customer-request-type-with-script-runner/qaq-p/120737/comment-id/1213#M1213
SELECT concat(lower(p.pkey),'/',vform.key) as value FROM jiraissue i , project p, issuetype t , AO_54307E_VIEWPORT vport, AO_54307E_VIEWPORTFORM vform WHERE p.id = i.project AND i.issuetype = t.id AND i.project = vport.project_id AND vport.id = vform.viewport_id AND vform.issue_type_id = t.id AND i.id = 'PROJECT-123';
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.