How to sync and map a component value to Select List (cascading) field

Originally asked by Helen Li on 26 November 2020 (original question)


Dear sir,

I want to know how to sync the customer’s components and map them to my Select List (cascading) field “FunctionGroup”.

I search the doc, no such examples, could you please help me? Thanks in advance.

Map fields
Customer JIRA instance My JIRA Instance
Component/s FunctionGroup Parent field
HW Hardware
Cluster Cluster
Infra Infra
BSP BSP
Android-HAL IVI
Audio Audio
MCU VIP
SRS SYS
aaaa Other
bbbb
cccc
dddd
….

Answer by Francis Martens (Exalate) on 27 November 2020

Cascading fields are documented in Syncing cascading select custom fields

Incoming Sync - Target Jira - Untested


// get the first component out of the components list sent over from the customer jira
def remoteComponentName = replica.components?.first().name

// component map allows to map the name of the component to the local value
def componentMapping = [
    // "remote component name" : "target parent"
    "HW" : "Hardware",
    "Cluster" : "Cluster",
    "Android-HAL" : "IVI",
]

// Find the mapped value, default to 'Hardware'
def targetValue = componentMapping[remoteComponentName] ?: "Hardware"

def parent = nodeHelper.getOption(issue, "FunctionGroup", targetValue)
issue.customFields."FunctionGroup".value = nodeHelper.getCascadingSelect(parent,"")

Let me know if this helps


Comments:

Helen Li commented on 30 November 2020

Greate. Thanks so much.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.