When doing a Clone to another project (using the Clone Plus Plugin), are you able to get the project key of the new project being cloned into?
I've been searching and testing all day.
issueContext.projectObject.key - Always returns the key of the issue being cloned from.
I tried variations of getFieldByName and getFieldByID with project/projects/Project/Projects and it always returns nulls.
I'm trying to use the Behaviours Plugin to hide fields depending on the selected project.
Thanks in advance.
In general with behaviours, we only have access to the information within the current screen and also from the context that is provided by Jira.
The methods we sent you in the support case here will give you access to the project selected in the default Jira Project Field when on the Create screen, and if you are on the edit screen it gives access to the underlying issue's project.
From the community post, it seems you are trying to access something from another plugin. We do not have any built-in methods that detect the variables this other plugin uses to tell the user the "New project Name".
If this plugin "Clone plus" stores the new project name/key in a field that we can access on-screen, then you should be able to use the default behaviours methods for getting field values by getting the FormField object and the calling getValue(). I have however tried to do this here to verify and although the field is on the screen and has the id "issue-create-project-name", its value is always null for both initialiser scripts and field server-side scripts. This means we cannot get the value of this field.
I have also looked at the context variables and they only contain the data of the current project and not the target project specified by your Clone Pluss addon.
The good news:
I had a deeper look into all possible variables on screen and it does appear there is one variable that stores the Project ID of the target project.
It is however only available when the form has been fully loaded which means you have to put the behaviour on a field and NOT an initialiser.
The summary field is usually on all these screens so you could attach the script to the summary field, then whenever the clone+ link is clicked it should trigger the behaviour script.
Here is an example you can use to get at the Clone Plus target project Object using the project Id pid. Refer to the atlassian-jira.log to see the log output results.
You mention Behaviour. I assume you mean the feature that comes with ScriptRunner.
A possible solution would be to create a listener on Issue Created event and in it check if the issue has an issue link of type Cloners. It's not a guarantee, but I think it's a good start.
Yes, I know that. I've tried both of those. Those don't seem to be getting what is displayed on the form.
You know how on the page at the very top it has the field "Project".
If you do a clone from one project to another, everything I've tried so far always gets the value of the original project being cloned from, I can't seem to be getting the value of the second project.
If I'm in project ABC and I want to clone the issue into XYZ, in the behaviours I want to get the value of XYZ which is displayed at the very top of the page.
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events