Hi,
What should be very simple has proved challenging getting the right syntax. I am successfully picking up the select fields value from the parent issue but despite the many variations I have tried to use I cannot get it copied over to the child issue,. Can someone tell me what I have done wrong?
def fldCustomer = contextIssue.getCustomFieldValue('Customer')
Hi @Peter Ellis
What you are trying to achieve is not directly doable via ScriptRunner Behaviour for the Issue Create screen. It is only doable on an Issue Update screen because the Sub-task is not yet linked to the parent issue on the create screen and cannot invoke the field values from the parent issue.
On the other hand, if you have a scripted field, i.e. like the issue picker, you can use it to indicate the parent issue and pass the value from it. I have provided a solution for this in this community post.
The other alternative would be to use the Post-Function, e.g. on the Create transition, where once the issue is created, it will pass the field values from the parent issue to the child issue.
Below is a very simple code sample using the Custom Script Post-Function for the Create transition:-
if (issue.subTask) {
def parent = issue.parentObject
issue.set {
setCustomFieldValue('Sample Text Field', parent.getCustomFieldValue('Sample Text Field'))
}
}
I am looking forward to your feedback.
Thank you and Kind regards,
Ram
Hi Ram,
Thank you for replying. I am currently copying over text and date data from the parent to the linked issue without any problem using script, see images. I just assumed that there is another syntax for select fields. I could use a post function but if there is a way to have this all in the same place that would be preferred.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Peter Ellis
From the screenshot you have shared, you seem to be trying to pass the value during the create screen.
As I mentioned in my previous comment, this will fail when using Behaviour because when the Create screen is displayed, the link between the parent and child issue is not yet established as the child issue doesn't yet exist.
Hence, Behaviour is not a suitable approach for this. You must instead use the Post-Function or the Listener.
However, if you intend to use Behaviour, it can only work when using the Edit screen or Transition screen.
I am looking forward to your feedback.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ram,
I didn't mention earlier but I am creating new issues via fragments so the parent is still in context when the related issue is created but not submitted.
I knew what I needed to do in the code for a select field (create an array, find the option ID and return it etc) I eventually worked it out and it's all working perfectly now.
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.