Question about 'Send a Custom Email' post function

Daniel Ehrlich April 23, 2014

We have a multiselect custom field that is being used as part of the condition conrolling the Send a Custom Email post function. Here is what is in the condition

cfValues["Send to Logrequest"].toString() == "Yes"

What is needed is to be able to reset this custom field to "No" or none after the email is sent. Adding the 'Clear Field Value' post function from the JIRA Suite Utilities plugin results in no email. Also tried the 'Set Field Value to constant or Groovy expression' from the JIRA Misc Workflow Extensions pluginwith the same result of no email being sent. And out of desperation added

<% cfValues["Send to Logrequest"] = null %>

to the end of the message template. Still no email.

A general question about post functions. Are they executed in the order displayed? Or some other order?

Any idea how to accomplish this? Thanks in advance.

1 answer

1 accepted

0 votes
Answer accepted
Tsol
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.
April 23, 2014

Check the order of post function execution.

Send custom email post function should executed before clear field value.

So if clear field value is executed first no email is sent.

You can change the order of post functions by click on the arrows. Check the screenshot below.

Hope that helps

Daniel Ehrlich April 23, 2014

The Send a Custom Email post function appears ahead of any of the other post functions that try to clear/reset the custom field.

Tsol
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.
April 23, 2014

Possibly your condition is wrong

try the following

cfValues['Send To Logrequest']*.value.contains('Yes')

Daniel Ehrlich April 23, 2014

The Send Email post functions *works* if the post function that tries to set/clear the custom field is removed. This has always been the case. It is as if the post functions are being excuted in parrallel or out of order.

Tsol
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.
April 23, 2014

Just reproduced it. You are right. Doesn't work if clear field value post function is used. No idea why this happens...

Daniel Ehrlich April 23, 2014

Hopefully, Mr. Eichlin will have some insight.

JamieA
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.
April 24, 2014

You could try a god-awful hacky workaround. Immediately fter the send email function, add a custom script post-function, which just contains:

Thread.sleep(700)

obviously this will delay the transition by half a second, but it should work.

JamieA
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.
April 24, 2014

Kostas is right on the condition script... it might work for you but it will also return true if the select contains something like "goldeneyes" - case notwithstanding.

It's because the send mail function starts a new thread, then pauses and sends the mail, to deal with a jira bug: https://jamieechlin.atlassian.net/browse/GRV-284

But your use case is valid, create an issue so you can track when it's done and I'll deal with it. But it will go in to the next major version... I'm not backporting anything at the moment.

JamieA
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.
April 24, 2014
Sven Peters February 3, 2015

Is there any other workaround available? I have the same issue with a script that alters the comment AFTER the custom email is sent. As the email uses the comment initially I need to keep the original comment with the sleep(700) before I alter it

Deleted user November 17, 2016

Hi i also had a similar problem but fixed it with the following function in scriptrunner:

  • Copy the email body to another customfield and the straight after clear the orginal customfield value. 

 

Suggest an answer

Log in or Sign up to answer