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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,869
Community Members
 
Community Events
184
Community Groups

Script to update a custom field based on service desk customer(email)

Hi Everyone, 

I am trying to implement service desk in my Organization, Based on the requirements, I need to update a custom field (either text field or single select) based on the service desk customer of that project.

for example: if a person with email's (abc@def.com) or raise a ticket from customer portal then the custom filed "company"must update with "DEF"

I am thinking that script runner might have a solution for this. 

I have very less knowledge on groovy scripting.

 

 

 

1 answer

1 accepted

2 votes
Answer accepted
Joanna Choules
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Dec 21, 2017

Hi,

The ScriptRunner documentation site has an article about Service Desk which describes how to do something very similar to what you want. If you're not interested in the fancy links etc. then here's a step-by-step approach:

  1. Go to the Script Fields tab and select Create a new Script Field.
  2. Configure the script field as follows:
    • Field Name: Whatever you want the field to be called, in your case 'company' or something similar.
    • Template: Text Field (multi-line)
    • Inline script:
    • issue.reporter?.emailAddress?.replaceAll(/.*@/, "")

One thing to note here is that the script will give you the entire domain name of the company (i.e. everything after the @ sign in the email address). For example, the email address "employee@company.co.uk" would produce a result of "company.co.uk". If you'd rather just have the first part of the domain name (i.e. everything between the @ sign and the first dot) then you can replace the above script with the following:

issue.reporter?.emailAddress?.replaceAll(/.*@/, "").replaceAll(/\..*/, "")

In this case, "employee@company.co.uk" would give the result "company".

Hope this is of some use!

Yours,

Jake

Hi  Jake, 

Thank you for your response, this works perfectly.

I have another question,

Lets say I have custom file with single select option with 50 options, is there any way that based on the domain an option should be populated automatically can we use if else functionality or something like that?

Thank you for your time.

Joanna Choules
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jan 02, 2018

Hi Anudeep,

I'd be happy to try and answer your follow-up question, although I would recommend that you post it as a new question in Community, so that users in future will be able to find it more easily.

When you post your question, if you would be able to specify the following things, then that would be helpful for me in determining the most appropriate solution:

  • Where do the options in the select box come from? Do they correspond to JIRA objects (e.g. users, projects) or have they just been typed in as free text/
  • Is it important that the field is a select box? In particular, is it important for users to be able to select a different option after it has been auto-populated?

Thanks.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events