• Community
  • Products
  • Jira
  • Questions
  • Behaviours's Validation Script(i,e Add-on->Behaviours->"Customfield") not enacted during the clone of multiple issues

Behaviours's Validation Script(i,e Add-on->Behaviours->"Customfield") not enacted during the clone of multiple issues

Hi,

Behaviours's Validation Script(i,e Add-on->Behaviours->"Customfield") not enacted during the clone of multiple issues using groovy script

Is there a way to achieve it?

When I create multiple clone issues using my groovy script, all Cloned issues are created successfully but Behaviours's Validation Script(i,e Add-on->Behaviours->Subsystem) written to map subsystem - "module owner" custom field value is not getting updated successfully in new issues.
is this not possible to enact using Behaviours Plugin Validation Script - when cloning issues using my below groovy script::


I believe cloneIssue() and createIssueObject() function will work with the condition added i,e (actionId == 1 && actionName == "Create" ) as part of my Validation Script(i,e Add-on->Behaviours->Subsystem) written to map subsystem - module owner custom field value.

/* clone of multiple Jira issues created using the below groovy script snipet in one of my project workflow, post function*/

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption
 
Issue issue = issue
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
 
//assuming this is a multiple select list custom field
def componentCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Component CF")
def selectedComponents = issue.getCustomFieldValue(componentCF)
 
//assuming this is a select list (single choice)
def subSystemCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Subsystem") 

selectedComponents?.each { LazyLoadedOption it ->     
def issueFactory = ComponentAccessor.getIssueFactory()     
def issueManager = ComponentAccessor.getIssueManager()     
def newIssue = issueFactory.cloneIssue(issue)  
 
// because the sub-system is a select list (single choice) we should find the option with that value (if any)
    def optionToSet = ComponentAccessor.getOptionsManager().getOptions(subSystemCF.getRelevantConfig(issue)).find {option -> option.value == it.value}
 
    // set the value of the custom sub-system and any other issue parameters you wish (project, assignee, etc)
    newIssue.setCustomFieldValue(subSystemCF, optionToSet) 
 
Map newIssueParams = ["issue":newIssue] as MapIssue newIssue1 = issueManager.createIssueObject(currentUser,newIssueParams) 
 
-------------------- 
}
/* Validation Script(i,e Add-on->Behaviours->Subsystem) written to map subsystem - "module owner" custom field value */
 
import org.ofbiz.core.entity.GenericValueimport com.atlassian.jira.issue.customfields.manager.OptionsManagerFormField
 
formComponent = getFieldById(fieldChanged)
FormField formSubcomponent = getFieldByName ("Module Owner")
FormField Release_Prime = getFieldByName ("Release Prime")
 
def actionName = getActionName()
def actionId = getAction().getId()
def componentFormValue = formComponent.getFormValue()
def componentValue = ""
def relPrimeVal=""
 
if((actionId == null && actionName == null)||(actionId == 1 && actionName == "Create" )|| (actionId == 1431 && actionName == "Change Subsystem")|| (actionId == 1441 && actionName == "Clone PR") ||(actionId == 771 && actionName == "Clone for All")|| (actionId == 811 && actionName == "Clone for All")|| (actionId == 1101 && actionName == "Restricted Update")|| (actionId == 1081 && actionName == "Restricted Update")){
 
formComponent.setReadOnly(false)
switch (componentFormValue)
{  case "10030" : //Agent
componentValue = "Platform-Support"    
relPrimeVal="Server-release"  
break    
 
case "10031" : //Automation tool  
componentValue = "automation"    
relPrimeVal="Server-release"  
break
 
case "-1" :  
componentValue = "kkadhu"    
relPrimeVal="Server-release" 
break
............. ............. 
} 
formSubcomponent.setFormValue(componentValue)
Release_Prime.setFormValue(relPrimeVal)
}
else
{    formComponent.setReadOnly(true)    
    Release_Prime.setReadOnly(true)
} 
 
/* The custom field "Module Owner" is defined as below in 'Add-on->Behaviours-> Module Owner' */
 
Field: Module Owner
Optional (Require)
Readonly (Writable)
Shown (Hide)

1 answer

0 votes

You've asked this several times already.

Yes Jamie, I agree.

In context of getting different scenarios clarification, I created this ticket.

Sorry for the confusion. Will discuss this same context in other ticket, where you had shared your feedback. Thanks.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,095 views 13 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot