Hello @Aldo_Ercolani
Here are the details:
Setting Request Type on Jira Service Desk Issues (Incoming Sync)
Note: Request Type can only be set at issue creation time. It cannot
be changed on existing issues
Step 1: Find the VP_ORIGIN Custom Field ID
Call the Jira REST API to get all fields:
GET https://<your_instnace>.atlassian.net/rest/api/3/field
In the response, search for the field with “custom”:“com.atlassian.servicedesk:vp-origin”:
{
“id”: “customfield_10010”,
“name”: “Customer Request Type”,
“schema”: {
“custom”: “com.atlassian.servicedesk:vp-origin”,
“customId”: 10010
}
}
Note the customId value (e.g., 10010).
Step 2: Find Request Type IDs
First, find your Service Desk ID:
GET
https://<yourinstance>.atlassian.net/rest/servicedeskapi/servicedesk
Response:
{
“values”: [
{ “id”: “3”, “projectKey”: “ITHD”, “projectName”: “IT Help Desk”
}
]
}
Then, fetch request types for that Service Desk (paginate if more han 50):
GET https://.atlassian.net/rest/servicedeskapi/servicedes
k/3/requesttype?start=0&limit=100
Response:
{
“values”: [
{ “id”: “25”, “name”: “Hardware Request” },
{ “id”: “26”, “name”: “Software Installation” },
{ “id”: “27”, “name”: “Report an Incident” }
]
}
Note the id for each request type you want to map.
Step 3: Incoming Sync Script
// ============================================================
// REQUEST TYPE MAPPING (only applied during issue creation)
// ============================================================
// VP_ORIGIN custom field numeric ID (from Step 1)
def vpOriginCfId = 10010L
// Map source issue type name → Jira Service Desk request type ID
(from Step 2)
def requestTypeMap = [
“Bug” : “25”,
“Service Request” : “26”,
“Incident” : “27”
]
// Resolve request type ID from source issue type
def sourceType = replica.type?.name
def requestTypeId = requestTypeMap[sourceType]
if (requestTypeId) {
def vpOrigin = new
com.exalate.basic.domain.hubobject.v1.BasicHubVpOrigin()
vpOrigin.requestTypeId = requestTypeId
def cfKey = "com.atlassian.servicedesk:vp-origin"
def cf = issue.customFields[cfKey]
if (cf != null) {
cf.value = vpOrigin
} else {
cf = new
com.exalate.basic.domain.hubobject.v1.BasicHubCustomField()
cf.setId(vpOriginCfId)
cf.setName(cfKey)
cf.setUid(cfKey)
cf.setType(com.exalate.api.domain.hubobject.v1_2.HubCustomFi
eldType.VP_ORIGIN)
cf.setValue(vpOrigin)
issue.customFields[cfKey] = cf
}
}
Customization
- Fixed request type for all issues: Replace the map logic with a
single ID:
def requestTypeId = “25”
- Map by other fields: You can map by any replica field, e.g.,
replica.priority?.name, replica.project?.name, etc.
Kindly let me know if this will work or not?
Thanks,
Sonal