Forums

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

Jira Post Function Email access value OptionID of a drop down field

Manuel Woletz March 27, 2019

Hi,

I have a question that is either very complex or to simple for me to see it. I'll describe the usecase for better understanding.

We are using Jira Service Desk and I have a deparment that should open up a ticket and another department should continue on this. As this is not possible with JSD (because emps are no agents) we have the folloing workarround:

One department opens the ticket and the post function sends an email to the other deparment with a deep link to the CreateIssue.jspa and the entered values are prefilled.

This works very well with text fields but not with Dropdown fields, as the CreateIssue.jspa does not expect the value of the Dropdown field but the OptionId of the option.

So the question is, how can I access the OptionID of a selected value of a dropdown field with in the "Send an E-Mail" Post Function Body.

Thanks a lot for your help

 

Manuel

1 answer

0 votes
Tarun Sapra
Community Champion
March 27, 2019

Hello @Manuel Woletz 

The option ID of the options of a select dropdown are fixed, please see the following quesitons as to how to retrieve them

https://community.atlassian.com/t5/Jira-Core-questions/How-to-know-value-or-ID-of-the-option/qaq-p/215665

Using script runner as well you can do it

https://community.atlassian.com/t5/Marketplace-Apps-questions/ScriptRunner-How-to-grab-the-ID-of-an-option/qaq-p/733802

Manuel Woletz March 27, 2019

Hi @Tarun Sapra I found some of this answers. The question is, how can I address this in the "E-Mail Body" field of the Post Function "Send E-Mail" script.

 

What I do in the E-Mail Body is to write the following:

 

<a hef=https://<myservicedeskurl>/servicedesk/secure/CreateIssueDetails!init.jspa?pid=10700&issuetype=10001&summary=Onboarding+Friedrich+Schiller&customfield_10818=Friedrich&customfield_10819=Schiller&customfield_10817=1/Apr/19&customfield_10820=mwoletz&customfield_10867=&customfield_10822=FRISCHI&customfield_10824=Leinfelden&customfield_10825=527>Click here</>

 

How can I reference  here the mentioned OptionID field?

Tarun Sapra
Community Champion
March 28, 2019

Hello @Manuel Woletz 

Did you try entering the custom field with the option id in string 

i.e. Id option id is "234" then customfield_1200="234" in the URL

Manuel Woletz March 29, 2019

Hi, yes I tried this, when I do it "manually" - but the link should be created in the Post Function Send E-Mail.

 

So the question is: when %{1200} returns e.g. "Leinfelden" - i need to have the %{<what_do_i_put_here} to get the result "234".

Do you know what I mean?

Thanks

Tarun Sapra
Community Champion
April 1, 2019

In order to get the Option ID you need to write code to fetch the id

https://community.atlassian.com/t5/Marketplace-Apps-questions/ScriptRunner-How-to-grab-the-ID-of-an-option/qaq-p/733802

And then store the value in a variable and then use that variable in the post-function email 

Manuel Woletz April 1, 2019

Ok thanks - I will try that today.

 

Manuel

Manuel Woletz April 1, 2019

Ok @Tarun Sapra hopefully last question - How do I access the defined variable from the post-function email? I tried % /  %{} /  $ / ${} neither works.


Thanks

Tarun Sapra
Community Champion
April 1, 2019

Hello @Manuel Woletz 

Can you please post the screenshots of your current post-function configuration.

Manuel Woletz April 2, 2019

emailbody.pngvariables.png

Manuel Woletz April 2, 2019

@Tarun SapraSo i have the post function that should put the OptionID in to a variable

and after that I have the email post function that accesses the customfields and needs to acceess the variables.

Thanks for you help

Manuel Woletz April 3, 2019

Any update on that @Tarun Sapra - I'd desperately need something here.

THANKS

Tarun Sapra
Community Champion
April 4, 2019

Hello @Manuel Woletz 

To send the custom email are you using the post-function by script runner or something else? As the post-function provided by the scriptrunner offers the ability to insert values from script.

https://scriptrunner.adaptavist.com/latest/jira/builtin-scripts.html#_send_a_custom_email

Manuel Woletz April 10, 2019

Hi @Tarun Sapra thanks we made some good progress here - just finetuning missing.

Thanks for you help!

 

Manuel

Suggest an answer

Log in or Sign up to answer