Environment - Adaptavist ScriptRunner v5.3.5 with JIRA v 7.4.4
Using a Post Function Script to clone a number of product-specific issues so the individual teams can work each individually. I have everything working except the ability to add multiple Component/s and populate a Cascading Select field.
Multiple Components: The following does us to set a single component, but need to add up to 5 different Components on several of the cloned issues. I searched online and could not find any examples on how to accomplish.
def projectComponentManager10 = ComponentAccessor.getProjectComponentManager()
def newcomponent10= projectComponentManager10.findByComponentName(project10.getId(), "FSU")
issue.setComponent([newcomponent10])
Populate a Cascading Select - I tried using the example found in the behaviours section, (https://scriptrunner.adaptavist.com/4.3.7/jira/recipes/behaviours/setting-default-fields.html#_setting_cascading_select_values) but no luck. I hacked around for 3 days and unable to find anything that works.
Any and all suggestions will be greatly appreciated.
Here is an example of one of the scripts in one of the Additional Issue Actions:
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.project.Project
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.watchers.WatcherManager
def project2 = issue.getProjectObject()
def componentManager = ComponentManager.instance
def optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class)
def userUtil = ComponentAccessor.getUserUtil()
MutableIssue issue = issue
def projectComponentManager2 = ComponentAccessor.getProjectComponentManager()
def newcomponent2= projectComponentManager2.findByComponentName(project2.getId(), "AOE")
issue.setComponent([newcomponent2])
def customFieldManager2 = ComponentAccessor.getCustomFieldManager()
def cf2 = customFieldManager2.getCustomFieldObjectByName("SV Lead")
ApplicationUser user2 = userUtil.getUserByKey("ploveman")
ApplicationUser user22 = userUtil.getUserByKey("")
List<ApplicationUser> newApprovers2 = []
newApprovers2.add(user2)
newApprovers2.add(user22)
def customFieldManager21 = ComponentAccessor.getCustomFieldManager()
def cf21 = customFieldManager21.getCustomFieldObjectByName("SV Management")
ApplicationUser user21 = userUtil.getUserByKey("pkerr")
ApplicationUser user212 = userUtil.getUserByKey("")
List<ApplicationUser> newApprovers21 = []
newApprovers21.add(user21)
newApprovers21.add(user212)
String SUMMARY_VALUE2 = issue.summary
String newSummary2 = "Security Vulnerability (AOE) - "+SUMMARY_VALUE2
issue.assigneeId = "aoe_triage"
issue.summary = newSummary2
issue.setCustomFieldValue(cf2, newApprovers2)
issue.setCustomFieldValue(cf21, newApprovers21)
checkLink = {link -> false};