auto add organization on creation of ticket

When a service desk agent creates a ticket, organization is not automatically added.

Is it possible to add this with the automation plugin or with scriptrunner?

Issue's created through the customer portel does auto add the organization

3 answers

1 accepted

Hi Laurens,

So a script listener during an Issue Created event would be 

import com.atlassian.fugue.Option
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.servicedesk.api.ServiceDeskManager
import com.atlassian.servicedesk.api.organization.OrganizationService
import com.atlassian.servicedesk.api.organization.OrganizationsQuery
import com.atlassian.servicedesk.api.util.paging.LimitedPagedRequest
import com.atlassian.servicedesk.api.util.paging.LimitedPagedRequestImpl
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

@WithPlugin("com.atlassian.servicedesk")

@PluginModule
ServiceDeskManager serviceDeskManager

@PluginModule
OrganizationService organizationService

MutableIssue issue = issue

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def serviceDeskProject = serviceDeskManager.getServiceDeskForProject(issue.projectObject)

// if the project is not a Service Desk one then do nothing
if (serviceDeskProject.isLeft()) {
    log.error "${serviceDeskProject?.left()?.get()}"
    return
}

def serviceDeskId = serviceDeskProject?.right()?.get()?.id as Integer

// get the available organizations for that project
def organizationsQuery = new OrganizationsQuery() {
    @Override
    Option<Integer> serviceDeskId() {

        return new Option.Some<Integer>(serviceDeskId)
    }

    @Override
    LimitedPagedRequest pagedRequest() {
        return new LimitedPagedRequestImpl(0, 50, 100)
    }
}

// get all the organizations configured for that project
def organizationsToAdd = organizationService.getOrganizations(currentUser, organizationsQuery)?.right()?.get()?.results

// get the Organizations custom field
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Organizations")

// finally update the organizations custom field
cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf), organizationsToAdd), new DefaultIssueChangeHolder())

What it actually does is if a project gets created (as you mentioned - not through the customer portal) then it will update the Organizations custom field in order to include all the Organizations configured for that project. Of course this script can be edited in order to match different criteria (if the reporter of an issue is member of any organization, etc..). The key thing in this script is the 'access' to the JIRA Service Desk API and a way to start using it. 

regards, Thanos

Hi

we recently started to use Jira Service Desk, we have used another service desk appliation.

in that app, you can add domain and when case created system knows the customer through the domain and add the organization.

Why do i run a script to catch the customer to add into organization.

it should be conguriable !!

is it a way to make automation rule to catch?

 

 

 

Hi Thanos,

 

could you also write a script where the organization is added automatically when an issue is created by a customer over the customer portal?

 

Thanks ;)

Hi Mari,

Thanks for you respons, but i don't see how that url gives a solution to my problem.

If a servicedesk Agent creates a ticket (not through the customer portal) an organization is not automatically added.

I want to do this automatically, now my agents need to manually fill in an organization after creating a ticket.

Is there a way to automatically add the organization in the cloud version ?

I'm currently running a trial of the cloud version and it seems this is still the case or am I just doing something wrong?


I've same problem. My agents can insert issue, by calling phone, so should be able to type customer name or organizzation. Is possible make this ? I tried to add organizzation to screen create issue, but it is not showed.

Same here. 

 

1) we can't show the field "Organisation" in the create screen

2) 98% of the time I want the organisation to be the reporter's organisation. 

 

If this could be done in "automation" i would be pleased

I am running into the same challenges with my implementation.

  1. If a customer who belongs to an organization creates a ticket via the portal, their organization will be added to the ticket unless they are members of more than on organization, then it will be a private request (Organization is null).
  2. If a Service Desk agent creates the ticket via the portal on behalf of the same customer, the organization will be added to the ticket unless they are members of more than on organization, then it will be a private request (Organization is null).
  3. In either scenario above, there is the option to Share the request with either organization while creating the ticket - but not both.
  4. If an agent is creating a ticket on behalf of a user using JIRA, there is no ability to manage the Organization and the Organization is not set even if the Reporter is changed to the customer.
  5. The Organizations field is be displayed and can be set on the JIRA Edit Screen after initial ticket creation.

There is a workaround to number 4 with the Extension for JIRA Service Desk plugin which has custom fields for Organization, Request Type, and Additional Participants.  The Organization custom field can be added to the Create Request screen in JIRA and you can select the customers Organization while you are creating the ticket.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,314 views 14 20
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot