Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

access to Issueproperty "request.channel.type" from groovy

Deleted user May 6, 2015

Hello there,

I have a groovy script that must perform an number of tasks with newly created issues from the SD customer portal. To make sure the newly created issue was created via the customer portal, I need to check the value of the Issueproperty "request.channel.type" for the value "Portal".
Up to now I did not find a way on how to get this property value.

Does someone know how to do this??

Regards, 

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Alejo Villarrubia [Adaptavist]
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 7, 2015

Hi @jan.van.de.klok,

This is what I've done to make it work:

import com.atlassian.jira.bc.issue.properties.IssuePropertyService
import com.atlassian.jira.component.ComponentAccessor

def userUtil = ComponentAccessor.getUserUtil()
def applicationUser = userUtil.getUserByKey("admin")

IssuePropertyService issuePropertyService = ComponentAccessor.getComponentOfType(IssuePropertyService)
def entityProperty = issuePropertyService.getProperty(applicationUser, issue.id, "request.channel.type").getEntityProperty()

if (entityProperty.getOrNull()) {
    log.debug("request.channel.type = " + entityProperty.get().value)
} else {
    log.debug("request.channel.type does not exist")
}

Hope it helps

Deleted user May 8, 2015

Hello Alejo, Unfortunatly it still does not work even not in your way. I'm beginning to suspect that there is a timing problem and that the property is not yet committed to the database or something like that. The script runs in a workflow postfunction directly after the issue is created and saved in the database.

Deleted user May 8, 2015

getOrNull returns false

JamieA
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 8, 2015

what kind of script are you writing... validator, or post-function? Possibly the JSD stuff happens in a listener which runs after your function.

Alejo Villarrubia [Adaptavist]
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 11, 2015

I noticed the property is not available until after the issue has been completely created. That means the script won't work if it's used in the create issue transition.

2 votes
JamieA
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 6, 2015
1 vote
Deleted user May 7, 2015

Thnx Jamie, 

 That works.....  (used getComponentOfType instead of getComponent)  but still no luck in accessing the property value. My code looks now like this:

 

IssuePropertyService issuePropertyService= (IssuePropertyService) ComponentAccessor.getComponentOfType(IssuePropertyService)

 

def propertyResult = issuePropertyService.getProperty(null,myIssue.getId(),"request.channel.type")

def prop = propertyResult.getEntityProperty()
String channel = propertyResult.getEntityProperty().getOrNull()

 

the database contains this data 

ID       ENTITY_NAME ENTITY_ID PROPERTY_KEY      CREATED                   UPDATED                 json_value
10999 IssueProperty  12343          request.channel.type 2015-05-08 08:18:10 2015-05-08 08:18:10 {"value":"portal"}

channel is still null !

 

I tried to pass the cuurent user instead of null as application user , still channel is null.

I tried to pass the default EntityPropertyOptions to by pass the permissions check , still channel is null. The default EntityPropertyOptions. skipPermissionsCheck() implementation results in false. I can't find a way to reimplement the method so it will deliver true. 

I'm not sure the permissions are the problem here.

Any suggestions to try next??

 

Jan  

0 votes
Deleted user May 6, 2015

Hi Jamie, 

    I did, but I didn't want to use REST services. I was looking for a java API to access that data. Could not find a way to instanciate a IssueProperyService   from ComponentAccessor  or ComponentManager. Do you??

I now (ab)use the "Customer Request Type" CF to determine the channel but I'd rather use the  request.channel.type property because I think it's more appriopriate.

Jan

 

JamieA
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 6, 2015
JamieA
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 6, 2015

Should be ComponentAccessor.getComponent(...) doesn't that work?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events