How to get issue's 'request.channel.type' property with jira api

Mack Chen July 23, 2018

Hi All,

    I want to get an issue's 'request.channel.type' property to judge which way created issue with jira api, I know the jira rest api can help me do it, and I tried use following way to do it in scriptrunner

ComponentAccessor.getComponent(JsonEntityPropertyManager.class).get("IssueProperty",issueId).get("request.channel.type")

this way only be useful for issue that I have created, but I need to judge it when I get issue create event, so anyone can help me ? Thanks!

1 answer

2 votes
Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 23, 2018

Hello @Mack Chen

Try this

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def issue = ComponentAccessor.getIssueManager().getIssueObject("TEST-1")

IssuePropertyService issuePropertyService = ComponentAccessor.getComponentOfType(IssuePropertyService.class)
def entityProperty = issuePropertyService.getProperty(user, issue.id, "request.channel.type").getEntityProperty()
Mack Chen July 23, 2018

Thanks @Mark Markov, I tried this way, and the result is the same as the way I have showed, it's useful for issue that I have created, when issue create event trigger my groovy, I want to get this issue's 'request.channel.type'

Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 23, 2018

The thing is that this property filling after ISSUE_CREATED event. This is how service desk api works.

As workaround, you can create listener on ISSUE_UPDATED event and catch whenever this field gets value.

Rajaravikiran S October 30, 2020

@Mark Markov the code works perfect!!! Thanks,

David Harkins
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 3, 2023

I needed to ensure i had the following also

import com.atlassian.jira.bc.issue.properties.IssuePropertyService
Andrea Hakim
Contributor
June 9, 2023

I tried this script and received the following as output:

some(EntityPropertyImpl[id=1566274,entityName=IssueProperty,entityId=657392,key=request.channel.type,value={"value":"portal"},created=2023-06-09 08:26:38.07,updated=2023-06-09 08:26:38.07])

How do I just grab - Portal

David Harkins
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 9, 2023

This is what I have:

 

def entityProperty = issuePropertyService.getProperty(UserASIWorkerBee, WorkingIssue.id, "request.channel.type").getEntityProperty()

def
ChannelType = entityProperty.get().value.toString()

return
ChannelType.substring(ChannelType.indexOf(':"')+2,ChannelType.indexOf('"}'))

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events