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

I am trying to Automate A project creation using the a Script



I have enabled a post function to run a script get value from Custom Fields and create project automatically. 


Script :- 

import com.atlassian.jira.bc.project.ProjectCreationData
import com.atlassian.jira.bc.project.ProjectService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.AssigneeTypes
import com.atlassian.jira.project.type.ProjectTypeKey
import org.apache.log4j.Logger
import org.apache.log4j.Level

def logg = Logger.getLogger("com.onresolve.scriptrunner.runner.ScriptRunnerImpl")

// the key for the new project from custom field
def projectKey = "Project Key"
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def projectKeyV = customFieldManager.getCustomFieldObjectByName(projectKey)
def getKeyV = issue.getCustomFieldValue(projectKeyV)"The Key is" + getKeyV )

// the name of the new project
def projectName = "Project Name"
def projectNameV = customFieldManager.getCustomFieldObjectByName(projectName)
def getNameV = issue.getCustomFieldValue(projectNameV)"The Key is" + getNameV )

def projectService = ComponentAccessor.getComponent(ProjectService)
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

// available project type keys: business | software | service_desk
def projectTypeKey = new ProjectTypeKey("software")

def creationData = new ProjectCreationData.Builder().with {

final ProjectService.CreateProjectValidationResult projectValidationResult = projectService.validateCreateProject(loggedInUser, creationData)
assert projectValidationResult.isValid() : projectValidationResult.errorCollection



I am getting an error when I am running this script


ERROR [workflow.AbstractScriptWorkflowFunction]: Workflow script has failed on issue JIRA-1731 for user 'Sunilkumar'. workflowMode=live&workflowName=New+JS+Workflow&descriptorTab=postfunctions&workflowTransition=481&highlight=1
java.lang.AssertionError: Errors: {projectType=An invalid project type was specified. Make sure the project type is available in your Jira instance. Please talk to your Jira administrator if you need more help.}
Error Messages: []. Expression: projectValidationResult.isValid()
	at com.onresolve.scriptrunner.runner.AbstractScriptRunner.runScriptAndGetContext(AbstractScriptRunner.groovy:174)
	at com.onresolve.scriptrunner.runner.AbstractScriptRunner$runScriptAndGetContext$3.callCurrent(Unknown Source)
	at com.onresolve.scriptrunner.runner.AbstractScriptRunner.runScriptAndGetContext(AbstractScriptRunner.groovy:293)
	at com.onresolve.scriptrunner.runner.AbstractScriptRunner$runScriptAndGetContext$2.callCurrent(Unknown Source)
	at com.onresolve.scriptrunner.runner.AbstractScriptRunner.runScript(AbstractScriptRunner.groovy:305)
	at com.onresolve.scriptrunner.runner.ScriptRunner$runScript$ Source)
	at com.onresolve.scriptrunner.canned.jira.utils.TypedCustomScriptDelegate.execute(TypedCustomScriptDelegate.groovy:19)
	at com.onresolve.scriptrunner.canned.jira.utils.TypedCustomScriptDelegate$execute$ Source)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CustomScriptFunction.execute(CustomScriptFunction.groovy:53)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CustomScriptFunction$execute.callCurrent(Unknown Source)
	at com.onresolve.scriptrunner.canned.jira.workflow.AbstractWorkflowCannedScript.execute(AbstractWorkflowCannedScript.groovy:20)
	at com.onresolve.scriptrunner.canned.jira.workflow.AbstractWorkflowCannedScript$execute$ Source)
	at com.onresolve.scriptrunner.jira.workflow.AbstractScriptWorkflowFunction$_run_closure2.doCall(AbstractScriptWorkflowFunction.groovy:89)
	at com.onresolve.scriptrunner.jira.workflow.AbstractScriptWorkflowFunction$_run_closure2.doCall(AbstractScriptWorkflowFunction.groovy)
	at com.onresolve.scriptrunner.runner.diag.DiagnosticsManagerImpl$DiagnosticsExecutionHandlerImpl$_execute_closure1.doCall(DiagnosticsManagerImpl.groovy:350)
	at com.onresolve.scriptrunner.runner.diag.DiagnosticsManagerImpl$DiagnosticsExecutionHandlerImpl$_execute_closure1.doCall(DiagnosticsManagerImpl.groovy)
	at com.onresolve.scriptrunner.runner.ScriptExecutionRecorder.withRecording(ScriptExecutionRecorder.groovy:13)
	at com.onresolve.scriptrunner.runner.ScriptExecutionRecorder$ Source)
	at com.onresolve.scriptrunner.runner.diag.DiagnosticsManagerImpl$DiagnosticsExecutionHandlerImpl.execute(DiagnosticsManagerImpl.groovy:348)
	at com.onresolve.scriptrunner.runner.diag.DiagnosticsExecutionHandler$execute$ Source)



1 answer

That's quite a specific error:

projectType=An invalid project type was specified


Before you build the ProjectCreationData - can you log all of the variables so we can see what is being built?

Can you also check the ApplicationManager whether it thinks that Jira Software is in fact installed? You can use this:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.application.api.Application;
import com.atlassian.application.api.ApplicationManager;
import com.atlassian.jira.application.ApplicationKeys;
import io.atlassian.fugue.Option;


boolean isJiraSoftwareInstalled() {
ApplicationManager applicationManager = ComponentAccessor.getComponent(ApplicationManager.class);
Option<Application> jiraSoftwareApplication = applicationManager.getApplication(ApplicationKeys.SOFTWARE);
return jiraSoftwareApplication != null;


Another thing you could try is sending a String instead of ProjectTypeKey variable to the 'withType( .. )' method, although your implementation certainly looks correct to me.

Hi Radek,


Thank You for the update, it was an issue on our end on JIRA software and it is working fine.

But, on the same note, can i use the above script to copy the configuration of a Project and create it?






Similar to it yes, you would want to use the following 2 instead:

Validation based on "fromExistingProject":


And then get a CreateProjectValidationResult from the "based on existing project" method:


This should get you the same result as if you went in the UI and used a "Create project based on existing template" feature.


However I must say I'm not familiar with Cloud or whether above is valid there (it is on Server), I did not verify nor have tried this with Cloud, I was however able to get this to work on Server in one of my assignments.


Note - creating based on existing project does what the UI does (from my experience, and again on Server). You still have to figure out how you want to handle project role actors and custom field contexts, but the above will get you a working project with the same schemes as the source project.




Hi Radek,


Thank You for the update, will give it a try. 




Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,171 views 8 28
Join discussion

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