Hi All,
I am using the Behaviours plugin to add behavior to a field.i want to add a Javascript snippet in my Groovy script .
Below is the js which i want to add in my Groovy script
<script type="text/javascript"> AJS.$("#versions option").each(function() { if( AJS.$(this).val() == 'optionId'){ AJS.$(this).remove(); } }); </script>
The optionId in the above code will be provided by the groovy script.
Is this possible ? if yes, how ? (examples with code will be appreciated )
Thank you .
In general it's not a good idea to have code write other code... it gets impossibly difficult to debug and deal with escaping issues.
But, I have not tried it, but if you write javascript using the setHelpText() method it will probably work.
What is it that you're tried to do, it looks like remove a version option that has the literal value optionId?
Hi Jamie ,
I am actually trying to set the options of a version picker . There is a parent child relationship between versions , this relationsihp is stored in an active object table , There are two customfields consider Parent ( A multi version picker) and child (a single version picker). I want to show only the parent versions in the Parent field and only child versions in the child field .
However due to this bug i am not able to set values to the Parent field.
So as a workaround i want to remove options from the Parent field which are child .
:( i have to complete this task this week
Did not get what setHelpText() does and how to include js using this method
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Was able to run the script using setHelpText() :) thanx .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How did you add script?
It doesnt allow <script> tags? in fact it doesnt allow any < or /> or </ charachters..
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It worked for me ... try escaing it \x3Cscript\x3E
You can use this http://www.htmlescape.net/stringescape_tool.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If possible paste your script here .. there might be some other escaping issue ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Mizan, for your help.
Here is the script i am trying to add:
getFieldById("summary").setHelpText ("\x3Cscript\x3Esssdadsasda;\x3C\x2Fscript\x3E")
This is the error i am getting (before saving)
Compilation failure: startup failed: Script1.groovy: 3: unexpected char: '\' @ line 3, column 39. getFieldById("summary").setHelpText ("\x3Cscript\x3Esssdadsasda;\x3C\x2Fscript\x3E") ^ 1 error |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok , dont escape the < > characters let it be <script> ... what is sssdadsasda ? the escaping issue might be in your script and not the <script> tag .. What is the real script you are trying to apply ?
Also you will need some imports try the below script
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
getFieldById("summary").setHelpText ("<script>sssdadsasda;</script>")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Mizan, for your help.
Here is the script i am trying to add:
getFieldById("summary").setHelpText ("\x3Cscript\x3Esssdadsasda;\x3C\x2Fscript\x3E")
This is the error i am getting (before saving)
Compilation failure: startup failed: Script1.groovy: 3: unexpected char: '\' @ line 3, column 39. getFieldById("summary").setHelpText ("\x3Cscript\x3Esssdadsasda;\x3C\x2Fscript\x3E") ^ 1 error |
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.