Question about 'Send a Custom Email' post function

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

This widget could not be displayed.

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

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

Possibly your condition is wrong

try the following

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

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.

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

Hopefully, Mr. Eichlin will have some insight.

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.

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.

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

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
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

300 views 1 4
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you