Hi,
I used the JIRA Misc Custom Fields to create a calculated number field. I also have Script runner plugin.
I want to send a custom email via a script runner post-function indicating the value of the calculated number field named Total cost.
When i preview the email, I do have the value of the Total cost field but when I get the email, the value is set as null next to the Total cost field. i tested with some standard number field and it perfectly works. So I assume that the calculated number field are not supported by the script runner email.
Would you have a solution as I need to automatically send the total cost to my client when I move the issue via a specific transition.
hope I'm clear
Thanks in advance for your help
Melissa
Hello Jaime / Thanos,
I am working with mel vega on this custom template. We have tried your suggestions but still it's not working. We also tried the following because it seems like the calculated field does not work well with the custom template actual email: 1) Added the "Copy Value From Other Field" so the calculated field (Total Number of MD Time & Material) value will be copied to a number field (Total Number of MD Time & Material (NUM)) 2) Created a custom script post-function so the calculated field (Total Number of MD Time & Material) value will be copied to a number field (Total Number of MD Time & Material (NUM)) But still, we are getting "null" for this fields on the actual email. I have noticed that even though we are using the post function to copy the value of calculated field to a number field, the value of the calculated field is not being copied. And if we set a temporary value on the number field, the value of this number field is being cleared after clicking the transition. Can you please advise if this is a plugin limitation for now or if you can suggest other things to make this work?
Thanks,
Lyka
Hi Lyka,
I found this https://innovalog.atlassian.net/browse/JMCF-5 may relates to your issue ("unfortunately, calculated fields are only shown on "view" screens, not "edit" or "transition" screens (because they are not editable)"). I saw you raised a support ticket therefore we will continue there.
Kind regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
Thanks for your answer.
I tried your suggestion but I still don't have in the email I receive the value of the total cost which should be 9 for example while the value is visible on the preview email.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
By the way, to be more precise, when I receive a notification email from Jira after updating the fields used to calculate the total cost field, I do see the update on those fields but not the new value of the total cost
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If it works in the preview but the actual email doesn't work, this is normally caused by using the dollar character. Try to use this: <% out << issue.assignee?.displayName %> rather than ${issue.assignee.displayName} For instance at the beginning where you include the issue type. Can you also try with a ScriptRunner script field. I don't see why the JMWE field would not work, but just to try to narrow down the problem...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie, I tried with a scriptrunner script field and teh result is the same : I do see the result of the sum in the preview email but not in the real email I get. do you think that I have to format something in the email configuration ? thanks and sorry to insist but I really need to be able to automatically send this piece of info to my client
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
sure! here you are tehe email template
Dear <% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("Requestor")) %>,
Here the estimated cost(s) the Issue $issue.issueType.name $issue.key $issue.summary you have raised :
Total Number of MD Time & Material : <% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("Total Number of MD Time & Material ")) %>,
Total Number of MD Fixed Price : <% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("Total Number of MD Fixed Price ")) %>,
Total Number of MD Fixed Rate : <% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("Total Number of MD Fixed Rate ")) %>
Collateral/Billing Cost (T&M): <% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("Collateral/Billing Cost (T&M) ")) %>
Regards, <% out << issue.assignee?.displayName %>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You seem to have trailing spaces on the end of your field names in the email template - do they actually have those trailing spaces? For the example calculated field you gave, you could just replace it with: issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObject("customfield_12345") ?: 0) %> because all it seems to be doing is replacing a null with a zero.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thanos,
thanks for your answer.
Could you tell me where to find or how to set up the string representation? (sorry I'm new in this!)
here you are the text I see when I click on the Preview button in the "send custom email " script post-function:
Body | Dear melissa, Here the estimated cost(s) the Issue !Test! -Issue type Change CHG-1023 test hidden fields-internal ticket you have raised : Total Number of MD Time & Material : 15.0, Total Number of MD Fixed Price : 0.0, Total Number of MD Fixed Rate : 0.0 Collateral/Billing Cost (T&M): 3.0 Regards, Melissa Vega |
and the final email I get :
Dear melissa,
Here the estimated cost(s) the Issue !Test! -Issue type Change CHG-1023 test hidden fields-internal ticket you have raised :
Total Number of MD Time & Material : null,
Total Number of MD Fixed Price : null,
Total Number of MD Fixed Rate : null
Collateral/Billing Cost (T&M): 3.0
Regards,
Melissa Vega
And i don't know if it can help here you are my custom field
image2016-1-6 10:20:26.png
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Melissa Could you please also paste your send custom email post function configuration screen ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Melissa
Did you try to get the string representation ( for example String.valueOf(0.1f) )? What type is the value of the custom field (double, float, int ?)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.