Hello to all,
I am using JIRA 6.2.3 and accidentaly upgraded Behaviours Plugin, that is no longer supported in JIRA 6.2.x. It was merged into Script Runner plugin. Now I have to restore some functionality with Script Runner, but code from Behaviours field definition
import com.atlassian.crowd.embedded.api.User import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.user.ApplicationUser FormField formTester = getFieldByName("Tester2"); ApplicationUser appUser = ComponentAccessor.getJiraAuthenticationContext().getUser(); User user = appUser.getDirectoryUser(); String currUserFullName = user.getDisplayName(); String currUserName = user.getName(); log.error (currUserFullName); log.error (currUserName); if(!formTester.getFormValue()){ formTester.setFormValue(currUserName); }
returns (when clicking at Go)
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script13.groovy: 5: unable to resolve class FormField @ line 5, column 11. FormField formTester = getFieldByName("Tester2"); ^ 1 error A stacktrace has been logged.
My task is to populate custom field Tester2 (customFieldId=11030) with username of reporter at the time of issue creation. User Picker is the template I have selected at script definition.
What should I import to be able to use class FormField, or is there any alternative to that class?
I would be grateful for any hint.
Leos
I recommend that you install Script Runner 3.0-beta, which you seem to already have, and uninstall the behaviours plugin. Obviously on a test instance first, hopefully it is not too late for that advice.
You cannot mix and match behaviours scripts with script runner scripts. Well, they are both groovy, except behaviours has specific methods available like getFieldByName, that are only available in the context where it makes sense.
Can you post a screenshot of where this is configured? That might help.
But your code, if it's a behaviours script, looks correct at first glance.
My response is below, as an answer, because "Sorry, our spambot thinks your comment is spam. Please post an answer instead."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have uploaded 3.0-beta-10 version of plugin via UPM and it works as before. Behaviours appeared again and they're working. Thanks :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jamie,
nice to hear from you. I cannot upgrade to 3-0beta. My version was the latest Script Runner available in Atlassian Marketplace (2.1.17) at the time of posting my question. According to page Installation of versions from 2.0.0 upwards I stopped JIRA, deleted old groovy-runner-all-*.jar files, download groovyrunner-3.0-beta-10.jar and moved it to ${CATALINA_HOME}/work/Catalina/localhost/_/WEB-INF/lib folder (JIRA was installed from WAR at Linux, it is run with root context) and started JIRA. But no plugin was installed or available in Find new addons menu, only Script Runner 2.1.17 is available for me. Have you publish step-by-step an upgrading guide when installing 3.0beta? Can you tell me what to do to perform upgrade?
Here is original version of behaviour code
<config use-validator-plugin="false" validate-jira-requiredness="false" name="PoleTester" description="Pole Tester se automaticky vyplnuje zadavatelem" guideWorkflow="null"> <field id="customfield_10013" required="null" readonly="null" hidden="null" validator="server" validator-class="" validator-script="import com.atlassian.crowd.embedded.api.User;&#13;&#10;import com.atlassian.jira.component.ComponentAccessor;&#13;&#10;import com.atlassian.jira.user.ApplicationUser;&#13;&#10; &#13;&#10; &#13;&#10;FormField formTester = getFieldByName(&quot;Tester&quot;);&#13;&#10;ApplicationUser appUser = ComponentAccessor.getJiraAuthenticationContext().getUser();&#13;&#10;User user = appUser.getDirectoryUser();&#13;&#10;String currUserFullName = user.getDisplayName();&#13;&#10;String currUserName = user.getName(); &#13;&#10; &#13;&#10;log.error (currUserFullName);&#13;&#10;log.error (currUserName);&#13;&#10; &#13;&#10;if(formTester.getFormValue() == &quot;&quot;){&#13;&#10;
if(formTester.getFormValue() == &quot;&quot;){&#13;&#10; formTester.setFormValue(currUserName);&#13;&#10; }&#13;&#10;}" validator-method=""/> </config>
I tried to separate groovy script, omitting JavaScript tags. But as you can see, I was not successful.
Regards
Leos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's a plugins2 plugin so you need to upload through the UPM.
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.