Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get new project key on Clone Plus plugin with Behaviours


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.

3 answers

1 accepted

0 votes
Answer accepted

Hi Jackson,

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.




This is great thank you! It worked well.

0 votes

Hi @Jackson Chang

Have you tried the app's support pages, where you can view their wiki or contact them directly? As it's a vendor they will have a more direct answer :)


Thank you for your help. I will open a support ticket.

Awesome - let us know if you locate the right solution :)


You mention Behaviour. I assume you mean the feature that comes with ScriptRunner.

If that's the case, you cannot do that - the Behaviour groovy code is translated into Javascript code that is injected into the web page. Cloning runs in the background and does not display any user-editable screen.

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.

That is correct, I am using ScriptRunner.

I believe Behaviours should let you some how get the "Project" field on the form.

That would solve it really easy. 

There are two ways to get the project key in a Behaviour script:

def projectObj = underlyingIssue?.getProjectObject() 
if (projectObj) {  
projectKey = projectObj.key   // Plan A
else {  
projectObj = getIssueContext().getProjectObject()  
projectKey = projectObj?.getKey()
  //plan B

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.

For example,

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.

So the next step is to open a support ticket with Adaptavist. You're paying big $$ for ScriptRunner, so you're entitled...

Thank you, I have opened one.

I'll provide what I find out here from them.

I really appreciate your help.

Suggest an answer

Log in or Sign up to answer

Community Events

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

Events near you