In the Script runner documentation sample for SubTasks Defaults fields, it is written:
"This script hinges on the parentIssueId being present in the form. As such, you will need to associate the script with a visible field. It will not work as an initialiser. "
I don't understand what I have to do to make it running? how can associate the script to a visible field?
Please help me on this point.
Thank you in advance
C.Maille
Hi Maille,
What this is explaining is that BECAUSE you need the parentIssueId, you CANNOT use the script in the initialiser. What this means is that you must use the script in ANY VISIBLE FIELD in the issue, in order for it to have access to the resources it needs to work.
Example:
1. I created a custom text field called "Tech Lead" for a given issue. This field just contains some text (a name).
2. If you take a look in behaviours and select the "Fields" operation for your desired behavior:
3. At this point, add a field to the beviour (NOTE: You can add ANY visible field and this should work, for the demo I am using my custom field)
4. Once you have added your field you just then need to add your script to the field as shown here:
That's it! Once your script is in, it should just work.
Note:
You need to edit the script in order to get it to migrate the values you want. Just reply if you need any help with that part :-)
Thanks,
Steve
Thank you very much for your quick answer. I tried to copy the script given as sample ; now I have an error in the script...
here is the begining of the script I tried to use and I got an error at the line import "unexpected token"
can you help me again? thank you in advance...
package com.onresolve.jira.groovy.test.behaviours.scripts
import
static com.atlassian.jira.issue.IssueFieldConstants.*
@BaseScript FieldBehaviours fieldBehaviours
FormField field = getFieldById(getFieldChanged())
...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much for your quick answer. I tried to copy the script given as sample ; now I have an error in the script...
here is the begining of the script I tried to use and I got an error at the line import "unexpected token"
can you help me again? thank you in advance...
package com.onresolve.jira.groovy.test.behaviours.scripts
import
static com.atlassian.jira.issue.IssueFieldConstants.*
..."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maille,
It is a typo in the script example. You just need to make sure import and static are on the same line.
Also I've just noticed, if you are putting it directly into the script editor, you don't need the "package" line either :-)
Thanks,
Steve
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
in fact I found that behind the import... we had some lines. If I add those lines it works better but not fully.
I have set the script for the field Summary and reduce it to have only 2 fields prefilled: Summary and Assignee, only the Summary is populated with the value of the Parent...
Do I miss something? or?...
here is the script
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.web.util.OutlookDate
import com.atlassian.jira.web.util.OutlookDateManager
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
import java.sql.Timestamp
import static com.atlassian.jira.issue.IssueFieldConstants.*
@BaseScript FieldBehaviours fieldBehaviours
FormField field = getFieldById(getFieldChanged())
FormField parent = getFieldById("parentIssueId")
Long parentIssueId = parent.getFormValue() as Long
if (!parentIssueId || field.getFormValue()) {
// this is not a subtask, or the field already has data
return
}
def issueManager = ComponentAccessor.getIssueManager()
def parentIssue = issueManager.getIssueObject(parentIssueId)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
// REMOVE OR MODIFY THE SETTING OF THESE FIELDS AS NECESSARY
getFieldById(SUMMARY).setFormValue(parentIssue.summary)
getFieldById(ASSIGNEE).setFormValue(parentIssue.assigneeId)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maille,
I created a basic Behaviour with the script that you gave me. I created a parent task with the summary and assigned user values populated. I then created a sub task and the summary and the assignee fields are both populated with the values from the parent. It looks as though your script works!
Could you send me a screenshot of your behaviour setup?
Thanks,
Steve
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.
Can I ask, what versions of JIRA and ScriptRunner do you have?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes sure:
JIRA Software 7.1.10
JIRA Core 7.1.9
Scriptrunner 4.3.6
I know that some new versions exist but I'm not the one who decide to take a new version...
I hope it will help
Christine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does it work if you swap out description for assignee?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes it works for summary and description... a problem with the Field Type? or the syntaxe?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I believe that this is an issue with the assignee field. There were bugs in earlier versions of the scriptrunner behaviours plugin around setting values on the assignee.
I would recommend that you update your plugin to the latest version. You'll get all the latest bugfixes and features, which will fix this issue.
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.
one more point: I wil check when I can install the new version...
waiting for this do you have a list about the fields where it works and the fields where we can have potential problems.
It will be very helpfull for me...
Anyway thank you very much for your help on this topic.
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.