• 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

This widget could not be displayed.

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 Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

84 views 0 1
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