It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Groovy change reporter in dependency of an custom field

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 Jul 04, 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).

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

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?

Hi Nir,

The script is working now. Thanks anyway.

Cheers,

Kristian

Nir Haimov Community Leader Jul 04, 2018

Hi Kristian,

Can you share what you did?

What did you change to make it work now?

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()
Nir Haimov Community Leader Jul 04, 2018

Yeah,

So you were only missing the

issue.store(); 

 

Thanks for sharing :)

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Desk

Tell us how you've implemented Change Management

Hello Community 👋, I'm a product manager at Atlassian, looking at improving change management capabilities across our products. In particular, we're looking at bridging the gap between Dev & ...

287 views 0 5
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you