After migrating to JIRA 7, from JIRA 6.4.3, the send email script listener does not work anymore.
The error in the logs is:
Script error: cannot cast object 'user' with class with class 'com.atlassian.jira.user.DelegatingApplicationUser' to class 'com.atlassian.crowd.embedded.api.User'
Please let me know if you need any other details.
Thank you.
Hi Cristina,
I can't see where you get a user from in the script you provided. Are you sure the error is coming from this post-function and not another one on the same transition?
For JIRA 7 your script should look like:
import com.atlassian.jira.component.ComponentAccessor def customFieldManager = ComponentAccessor.getCustomFieldManager() def cf = customFieldManager.getCustomFieldObjects(issue).find { it.name == 'Process Area' } def passesCondition = false if (cf != null) { def fieldConfig = issue.getCustomFieldValue(cf) if (fieldConfig.toString().contains('System Architecture')) { passesCondition = true } else { passesCondition = false } }
Thanks,
Adam
Hello,
There is indeed no user type object in the script, the problem is that I set an email address. This is a listener that sends emails, and the error is related, I think, to how script Runner calls the method that sends emails. I have a few email addresses configured in the 'to' section' of the listener and the error, I think, is related to that.
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you include a screenshot of how you have your listener configured? Are you also able to send the message you get in the logs when the listener runs? There may be more to the message which will give us some clues.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
email1.pngemail2.png
Hello @Adam Markham, I added the screenshots of the configuration, and the error message:
2017-02-10 01:33:09,411 http-nio-8080-exec-16 ERROR uidq5816 93x37102x1 1h6f0qr 10.226.16.124 /secure/QuickCreateIssue.jspa [c.o.s.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: SEPG-844, actionId: 1, file: <inline script>
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'uidq5816(uidq5816)' with class 'com.atlassian.jira.user.DelegatingApplicationUser' to class 'com.atlassian.crowd.embedded.api.User'
at Script272.run(Script272.groovy:20)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Cristina,
Thanks for that. I don't see anything wrong with the configuration. I guess process area and system architecture custom fields are not user picker ones?
Adam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Adam,
"Process Area" is a custom field, a list select. "System Architecture" is a value inside the "Process Area" custom field.
Basically, what we are trying to do is:
When somebody creates a ticket and selects the value "System Architecture" for the "Process Area" custom field, then an email should be sent to the leaders of that area.
In JIRA 6.4.3 it used to work. Now we get the error that I added above.
I hope this is clearer now, please let me know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Please let me know if you have any updates on this , or if you need additional info.
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Cristina,
Are you really sure that the send custom email cause this error ? Do you have any custom post functions or custom listeners ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Thanos Batagiannis [Adaptavist],
Yes, going to Script Listeners, we selected: 'Send a custom email', then we added the condition and the template. When trying to create an issue for which we expect an email, we do not get the email, and in the logs we find the error mentioned above.
I attached 3 more screenshots to see that this is the case. email3.pngemail2.pngemail1.png
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cristina,
Sorry for asking the same question twice, but could you please check at Built in Scripts -> Script Registry for other Script Runner Listeners or Post Functions or Validators or Conditions that are not properly updated in order to match the JIRA v7 API.
I am asking that because if there was a bug in the Send Custom Email Listener something similar to the stack trace below would appear to your logs
2017-02-15 17:27:44,397 http-bio-8080-exec-3 ERROR admin [onresolve.scriptrunner.runner.AbstractScriptListener] ************************************************************************************* 2017-02-15 17:27:44,398 http-bio-8080-exec-3 ERROR admin [onresolve.scriptrunner.runner.AbstractScriptListener] Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, script: com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail groovy.lang.MissingPropertyException: No such property: illegalProperty for class: com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.sendMail(SendCustomEmail.groovy:536) at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$sendMail$6.callCurrent(Unknown Source) at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.doScript(SendCustomEmail.groovy:558)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Rafael Franco [Adaptavist],
Here is the script:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.ManagerFactory
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.context.IssueContext
import com.atlassian.jira.issue.context.IssueContextImpl
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.fugue.Option
import org.apache.log4j.Category
import com.atlassian.jira.util.JiraUtils;
import org.ofbiz.core.entity.GenericValue;
import com.atlassian.jira.issue.MutableIssue
def componentManager = ComponentManager.instance
def compAccessor = new ComponentAccessor()
def customFieldManager = compAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Process Area'}
def passesCondition = false
if(cf!=null){
def fieldConfig = issue.getCustomFieldValue(cf)
if(fieldConfig.toString().contains('System Architecture'))
passesCondition = true
else
passesCondition = false
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Cristina Abunei can you please reedit your post using the "code" option in the editor otherwise becomes hard to read? Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello, I edited the code.
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Cristina,
Can you provide us with your current script so we can take a look?
Regards,
Rafael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.