Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Populating custom fields based on ticket data

CHASE MAIMBOURG January 25, 2021

The title is a little vague. I'll explain my use case.

 

Let's say user1@contoso.com emails support, and it generates a ticket. Here's what I want to happen:

  1. See "contoso.com" and change a custom field "Customer" to "Contoso Inc"
  2. See the customer is "Contoso Inc" and change custom field "Team" to "Team one"
  3. Assign the ticket to that team.

 

I have 1 working using ScriptRunner. I have a simple hash table that has all the customers and their domains. It gets the reporter email and sets the customer.

I could technically make another identical rule, with another hashtable with every customer, and the team associated with them, but that just seems dirty. I'd really like a way to store the associations outside a hash table in a Groovy script.

 

What I'd like to do, is store the customers in a DB, and have "Name", "Team" and "Domains" as fields. So if Customer = "Contoso Inc" then customer.team = "Team one" and link these in the custom field, so if "Customer" is set, it sets the team, and any other fields I add down the line.

I'm 100% open to using external plugins for this, just wanted to see if anyone has anything similar setup before hammering at it for the next few days.

2 answers

0 votes
Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 25, 2021

Using the example of the Automation rule, you could use project properties as keypair storage. The developer document about entity properties has a bit more information about how the keypairs work.

Using a PUT call, you can set the key as the customer name, and the value as the team you want to use.

I'm happy to see you've got the customer mapping (#1 on your list) sorted with Scriptrunner. This is more or less the gist of JSDSERVER-4417 and JSDSERVER-4519 - you'd like the email domains to correspond with a particular customer/organization. I do see a couple Marketplace apps that help out in this area as well - I'd recommend looking through the Marketplace results but at the time of this answer I see a couple apps that claim to do the email association from their listings:

Since we're talking Automation, there's also a straightforward way to set this in an Automation rule. 

Now for the Automation trick - Automation can let you use variables as well as custom field data, and it can do REST API calls with the send web request action. You can have one send web request action in your rule that fetches your project property keypair data from Jira's own REST API, using the organization name as a variable in the request URL as the key. See documentation on the send web request action here - when running this rule you'll need to provide an account credential in the call that has permission to browse the Jira project. It doesn't have to be an admin like you'd need to do a PUT request, but you do need an account with at least browse permission on the project for the GET request to return with your keypair. The account credentials for this call are stored as header information in the rule - so anyone with project admin can retrieve them. Don't store your own account credentials here; but a limited-purpose service account should be ok.

The result from your GET request can be parsed using the webhookReponse smart value. This lets you use the value in further rules down the line - such as setting more custom field values or assigning the issue.

0 votes
Taranjeet Singh
Community Champion
January 25, 2021

@CHASE MAIMBOURG  If you already have 1 working, I think you can achieve 2 by creating an automation rule, using "Automation for Jira" add-on.
What you can basically do is to create an automation rule that gets triggered on issue updated event for your project, has multiple if/if-else conditions & corresponding actions (one for each Customer and Team combination). This rule should be able to check the value in "Customer" field as part of the condition and accordingly set up value of "Team" field as part of the action.

For this, you will first need to create your custom field "Team" with all the values, in Jira itself.

 

I hope this helps!

CHASE MAIMBOURG January 25, 2021

@Taranjeet Singh 

I definitely think that would work, but it would require 100+ else if statements, 1-2 per customer. With no good way to mass create those rules in the automation for jira gui, you can imagine the 2-3 clicks per else if could get very clunky..

 

Right now I have a hash table in a Scriptrunner script, but I'd really like to pull these from a database if possible

Suggest an answer

Log in or Sign up to answer