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,
Community moderators have prevented the ability to post new answers.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
getOrNull returns false
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
what kind of script are you writing... validator, or post-function? Possibly the JSD stuff happens in a listener which runs after your function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you look at using IssuePropertyService to get it: https://developer.atlassian.com/jiradev/jira-architecture/building-jira-add-ons/jira-entity-properties-overview ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the java API is mentioned in that: https://docs.atlassian.com/jira/latest/com/atlassian/jira/bc/issue/properties/IssuePropertyService.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Should be ComponentAccessor.getComponent(...) doesn't that work?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.