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

Groovy change reporter in dependency of an custom field

AccessHolding July 3, 2018

Hi All,

I have a script in place which should change the reporter after the creation phase (post-function). The source of the new reporter is a single-user-picker. The idea is, as soon as somebody creates a ticket for someone else I want that the "someone else" will be set as the new reporter. I am using JIRA 7.8.0 with JIRA SD 3.11 and cant find my mistake.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue

MutableIssue issue = issue

def onBehalfOfCustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("ASD: On behalf of")
def onBehalfOfValue = issue.getCustomFieldValue(onBehalfOfCustomField)

if (onBehalfOfValue){
    issue.setReporter(onBehalfOfValue)
}

Best,

Kristian

1 answer

1 accepted

0 votes
Answer accepted
Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 4, 2018

Hi,

 

I'm using Jira 7.3.3 Jira SD 3.4.0

When someone create a ticket (from customer portal) on behalf of someone else.

That someone else is automatically the reporter (no need for script or something).

AccessHolding July 4, 2018

Hi Nir,

Would you please explain me your environment? Our customers need to login first before they are able to create tickets. Means the system choose them as a default reporter each time as soon they create a ticket. 

It was necessary to create custom fields and add this fields to each request type. I am curious how your environment looks like.

Best,

Kristian

Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 4, 2018

Hi,

I understand the issue now.

I meant for the option that exist here:

https://confluence.atlassian.com/servicedeskcloud/raising-requests-on-behalf-of-customers-747602734.html

As admin, you can create ticket on behalf of someone (built in in JSD).

But you want the customers to have this feature, so you created a custom field and you are trying to use a script on it.

 

Well, what the script logs says?

Did it pass successfully and just did nothing or it fails?

If it fails, what are the errors?

AccessHolding July 4, 2018

Hi Nir,

The script is working now. Thanks anyway.

Cheers,

Kristian

Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 4, 2018

Hi Kristian,

Can you share what you did?

What did you change to make it work now?

AccessHolding July 4, 2018

I created a custom field. As soon this field is not null the value will be set as a new reporter. The sweet part of it is, that a user could raise a ticket for an colleague without getting any notificaiton.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.MutableIssue

MutableIssue issue = issue

def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("ASD: On behalf of")
def newReporter = issue.getCustomFieldValue(customField) as ApplicationUser

if (customField){
    issue.setReporter(newReporter)
}

issue.store()
Like Kuhlemann likes this
Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 4, 2018

Yeah,

So you were only missing the

issue.store(); 

 

Thanks for sharing :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events