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

How to populate a custom field based on the email domain of the reporter

Sometimes, it is necessary to use the department or location the user belongs to in JQL filters. Natively this option is not available in Jira even if this value is present in the user's profile.

The details like Department, job title, organization etc, that are shown on an Atlassian account's profile or that are synced from the IDP are not available to be used as a field in Jira. There is a feature request suggesting the implementation of this ability:

The option presented below could be a workaround which would be useful to populate a custom field based on the subdomain present in the user's email.

The following are pre-requisites for this to be a success: 

  1. The rule would only work if the users had subdomains in the email address
  2. Automation service limits would have to be respected so there needs to be a limit to the number of subdomains that are checked.
The smart value to get the domain part of the email address is "reporter.emailaddress.split("@").last"

As shown below, I was able to get a custom field called 'Dept' populated with the value based on the reporter domain. Here, the custom field Dept was of type Text field. 

  • Trigger: Field value changed.
    • Fields to monitor for changes: Reporter;
    • Change type - any changes to the field value.
    • For - All issue operations.
    • image.png
  • Action: Create variable 
    • Variable Name - Domain, Smart value - 
      {{reporter.emailaddress.split("@").last}}
    • image.png
  • If/else block - use advanced compare conditions 
    • Domain equals <atlassian.com>
    • image.png
    • Edit Issue fields - set Dept value Location 1
    • image.png
    • First value - Domain equals <gmail.com>
    • image.png
    • Edit Issue fields - set Dept value Location 2
    • image.png

 

The rule runs when a new issue is created or when the reporter field changes and the field Dept is not populated with a value as shown below:

image.png

We can now use the field Dept in a JQL query - for example to get a list of tickets created where the Dept is set to Location 2 as seen below:

image.png

Note - 1:

The trigger used in my example above is Field Value changed. As per the documentation, this includes any changes to the field value (Value added, value deleted or any changes to the field value) due to any of the actions as highlighted in the screenshot below.

automation-trigger.png

So the value of the reporter changing/being set when the ticket is created would also be included in this trigger.

Note - 2:

If there are many if/else clauses to check, a lookup table could also be created for this purpose, thus also simplifying the automation rule, but that is out of scope of this article :) 

Including the documentation for that below:

References:

2 comments

Curt Holley
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 3, 2023

I like it and have done almost the same thing. Only difference, my variable is {{issue.Reporter.emailAddress}} and my If/Else conditions are, If {{email}} (variable name) contains @domain.name Then populate Dept field with appropriate entry. 

Like Bhaargavi Natarajan likes this
Steve Morrell
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 22, 2023

Is there a way to do this with any email domain, where you can't predict the domain?

For example if it comes from a user john.smith@acme.com, can you pull out the "acme.com" and then set a custom field to be "acme.com".

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events