2
1
0
Hi! How do I sync the value chosen in Project 1 (in a custom field, single select list) with Component/s field in receiving Project 2? This is a local sync. /Robin
  1. Francis Martens (Exalate)

    Do you have a mapping between the options in the custom field and the components?

  2. Robin Essman

    issue.components = replica.customFields.“MSL
    Component/s”?.value?.value.collect{
       nodeHelper.createComponent(
          issue,
          it.name,
          it.description,
          it.leadKey,
          it.assigneeType.name()
          )
       }


    Is this the correct way to set a component from a single select custom field? 
    And I need to understand if it duplicates/creates new components or if it sets the component that actually exists in the receiving project. 

CommentAdd your comment...

2 answers

  1.  
    2
    1
    0

    Hi Marika,


    I have tested this approach out so I can finally give you a concrete answer.


    Keep in mind that this will only work if your options for the Single Select Custom Field match with the names of the components on the destination side:


    Make sure to change "Select List Test" to the actual name of your custom Field on both sides (smile)


    Outgoing (source side):

    replica.customFields."Select List Test" = issue.customFields."Select List Test"



    Incoming (destination side):

    def selectListOption = replica.customFields."Select List Test"?.value.value
    def component = nodeHelper.getComponent(selectListOption, nodeHelper.getProject(issue.projectKey))
    issue.components += component


    Thanks,


    André

    1. Marika Trygg

      Works like a charm!

      Thank you for your help!

      /Marika

    CommentAdd your comment...
  2.  
    1
    0
    -1

    Hello,

    I tried in incoming rule as below


    if(firstSync){
       // If it's the first sync for an issue (local issue does not exist yet)
       // Set project key from source issue, if not found set a default
       //issue.projectKey   = nodeHelper.getProject(replica.project?.key)?.key ?: "TEST"
       //issue.projectKey = replica.customFields."Autoliv Partner"?.value?.value
       // issue.projectKey = replica.components.collect(it.name)
       //issue.projectKey = replica.components.collect { remoteComponent ->
        //    nodeHelper.getComponent( remoteComponent.name) }
       // Set type name from source issue, if not found set a default
    //   issue.typeName     = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Task"
        def componentNameToProjectMap = ["Ansible Automation Project":"ANSIBLE","Change Dashboard":"CHD"]
        issue.projectKey   = replica.components.collect { component -> componentNameToProjectMap[component.name] }.find{it != null} ?: "STTEST"
        syncHelper.syncBackAfterProcessing()
        issue.type = replica.type
        def selectListOption = replica.customFields."JIRA Component"?.value.value
        def component = nodeHelper.getComponent(selectListOption, nodeHelper.getProject(issue.projectKey))
        issue.components += component
    }



    I got the below error:


    Error Type:
    Incoming sync: first sync error
    Error Creation Time:
    2020-12-03 11:51:02.073
    Error Detail Message:
    Script error details: No signature of method: com.exalate.node.hubobject.v1_3.NodeHelper.getComponent() is applicable for argument types: ([C, com.exalate.basic.domain.hubobject.v1.BasicHubProject) values: [TC2, com.exalate.basic.domain.hubobject.v1.BasicHubProject@74809f4f] Possible solutions: getComponent(java.lang.String), getComponent(java.lang.String, com.exalate.api.domain.hubobject.v1_2.IHubProject). Error line: Script23.groovy:16
    Error Stack Trace
    com.exalate.api.exception.script.CreateProcessorException: Script error details: No signature of method: com.exalate.node.hubobject.v1_3.NodeHelper.getComponent() is applicable for argument types: ([C, com.exalate.basic.domain.hubobject.v1.BasicHubProject) values: [TC2, com.exalate.basic.domain.hubobject.v1.BasicHubProject@74809f4f] Possible solutions: getComponent(java.lang.String), getComponent(java.lang.String, com.exalate.api.domain.hubobject.v1_2.IHubProject). Error line: Script23.groovy:16 at com.exalate.error.services.ScriptExceptionCategoryService$.wrapAsCreateProcessorException(ScriptExceptionCategoryService.scala:54) at com.exalate.processor.jira.JiraCreateIssueProcessor.createIssue(JiraCreateIssueProcessor.java:163) at com.exalate.replication.request.CreateIssueSyncRequestState.transition(CreateIssueSyncRequestState.java:73) at com.exalate.replication.request.CreateIssueSyncRequestState.transition(CreateIssueSyncRequestState.java:24) at com.exalate.replication.in.RequestProcessorService.processSyncRequest(RequestProcessorService.java:324) at com.exalate.replication.in.RequestProcessorService.processSyncRequestsForIssue(RequestProcessorService.java:194) at com.exalate.replication.in.RequestProcessorService.processSyncRequests(RequestProcessorService.java:131) at com.exalate.replication.in.RequestWorker$1.run(RequestWorker.java:91) at com.exalate.node.util.concurrent.ClusteredSensitiveExecutorService$1.run(ClusteredSensitiveExecutorService.java:32) at com.exalate.node.util.concurrent.ClusteredSensitiveExecutorService$1.run(ClusteredSensitiveExecutorService.java:28) at com.exalate.node.util.concurrent.ClusteredSensitiveExecutorService.executeHandlingLocks(ClusteredSensitiveExecutorService.java:54) at com.exalate.node.util.concurrent.ClusteredSensitiveExecutorService.executeHandlingLocks(ClusteredSensitiveExecutorService.java:28) at com.exalate.replication.in.RequestWorker.run(RequestWorker.java:81) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: com.exalate.api.exception.script.ScriptException: No signature of method: com.exalate.node.hubobject.v1_3.NodeHelper.getComponent() is applicable for argument types: ([C, com.exalate.basic.domain.hubobject.v1.BasicHubProject) values: [TC2, com.exalate.basic.domain.hubobject.v1.BasicHubProject@74809f4f] Possible solutions: getComponent(java.lang.String), getComponent(java.lang.String, com.exalate.api.domain.hubobject.v1_2.IHubProject). Error line: Script23.groovy:16 at com.exalate.error.services.ScriptExceptionCategoryService.categorizeProcessorAndIssueTrackerExceptionsIntoScriptExceptions(ScriptExceptionCategoryService.scala:36) at com.exalate.processor.ExalateProcessor.executeProcessor(ExalateProcessor.java:48) at com.exalate.processor.jira.JiraCreateIssueProcessor.executeCreateProcessor(JiraCreateIssueProcessor.java:291) at com.exalate.processor.jira.JiraCreateIssueProcessor.createIssue(JiraCreateIssueProcessor.java:145) ... 18 more Caused by: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.exalate.node.hubobject.v1_3.NodeHelper.getComponent() is applicable for argument types: ([C, com.exalate.basic.domain.hubobject.v1.BasicHubProject) values: [TC2, com.exalate.basic.domain.hubobject.v1.BasicHubProject@74809f4f] Possible solutions: getComponent(java.lang.String), getComponent(java.lang.String, com.exalate.api.domain.hubobject.v1_2.IHubProject) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:151) at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) at com.exalate.processor.ExalateProcessor.execute(ExalateProcessor.java:73) at com.exalate.processor.ExalateProcessor.executeProcessor(ExalateProcessor.java:46) ... 20 more Caused by: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.exalate.node.hubobject.v1_3.NodeHelper.getComponent() is applicable for argument types: ([C, com.exalate.basic.domain.hubobject.v1.BasicHubProject) values: [TC2, com.exalate.basic.domain.hubobject.v1.BasicHubProject@74809f4f] Possible solutions: getComponent(java.lang.String), getComponent(java.lang.String, com.exalate.api.domain.hubobject.v1_2.IHubProject) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:348) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:145) ... 23 more Caused by: groovy.lang.MissingMethodException: No signature of method: com.exalate.node.hubobject.v1_3.NodeHelper.getComponent() is applicable for argument types: ([C, com.exalate.basic.domain.hubobject.v1.BasicHubProject) values: [TC2, com.exalate.basic.domain.hubobject.v1.BasicHubProject@74809f4f] Possible solutions: getComponent(java.lang.String), getComponent(java.lang.String, com.exalate.api.domain.hubobject.v1_2.IHubProject) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:56) at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) at Script23.run(Script23.groovy:16) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:345) ... 24 more


    Can you please advise ?

    1. Sam

      Can someone help please ?

    2. Sam

      any update please ?

    3. Mariia Horbatiuk

      Hello Sam, 

      Can you please let me know if "Jira Component" CF is a multiple option CF?


      If that's the case, please try the following:


      def selectListOption = replica.customFields."JIRA Component"?.value.value?.find()
    4. Sam

      we usually have a single component for the Sync, shall I try suggested statement in target JIRA server ?

    5. Juan Grases

      Hi Sam, 


      Your code indicates that you are using a custom field on the source side (JIRA Component), what would be it's type? We are trying to understand why your code didn't work, as it should work fine in the case that custom field "Jira Component" is of type Single Select List


      Thanks,

      Juan

    6. Sam

      Hello Juan,


      The JIRA Component custom field is from the type: 

      Text Field (single line)


      Thanks

      Sam

    7. Juan Grases

      In that case, could you try this line:

      def selectListOption = replica.customFields."JIRA Component"?.value

      And let me know if it works.

    8. Sam

      Hello Juan,


      I got the below error:


      Error Detail Message:
      Exalate has problems while trying to create an issue in this Jira. Details: [InvalidInputException: [Error map: [{components=Component/s is required.}]] [Error list: [[]]]
      Error Stack Trace
      com.exalate.api.exception.IssueTrackerException: Exalate has problems while trying to create an issue in this Jira. Details: [InvalidInputException: [Error map: [{components=Component/s is required.}]] [Error list: [[]]] at com.exalate.node.compatibility.CompatibilityService.createIssueObject(CompatibilityService.java:657) at com.exalate.node.hubobject.v1_4.NodeHubIssueHelper.createIssue(NodeHubIssueHelper.java:541) at com.exalate.node.hubobject.v1_4.NodeHubIssueHelper.createIssueWith(NodeHubIssueHelper.java:458) at com.exalate.compatibility.HubObjectHelperAdapter.createNodeIssueWith(HubObjectHelperAdapter.java:42) at com.exalate.hubobject.v1_2.HubObjectHelper.createNodeIssueWith(HubObjectHelper.java:316) at com.exalate.processor.jira.JiraCreateIssueProcessor.applyProcessorResult(JiraCreateIssueProcessor.java:358) at com.exalate.processor.jira.JiraCreateIssueProcessor.applyProcessorResult(JiraCreateIssueProcessor.java:334) at com.exalate.processor.jira.JiraCreateIssueProcessor.createIssue(JiraCreateIssueProcessor.java:160) at com.exalate.replication.request.CreateIssueSyncRequestState.transition(CreateIssueSyncRequestState.java:73) at com.exalate.replication.request.CreateIssueSyncRequestState.transition(CreateIssueSyncRequestState.java:24) at com.exalate.replication.in.RequestProcessorService.processSyncRequest(RequestProcessorService.java:324) at com.exalate.replication.in.RequestProcessorService.processSyncRequestsForIssue(RequestProcessorService.java:194) at com.exalate.replication.in.RequestProcessorService.processSyncRequests(RequestProcessorService.java:131) at com.exalate.replication.in.RequestWorker$1.run(RequestWorker.java:91) at com.exalate.node.util.concurrent.ClusteredSensitiveExecutorService$1.run(ClusteredSensitiveExecutorService.java:32) at com.exalate.node.util.concurrent.ClusteredSensitiveExecutorService$1.run(ClusteredSensitiveExecutorService.java:28) at com.exalate.node.util.concurrent.ClusteredSensitiveExecutorService.executeHandlingLocks(ClusteredSensitiveExecutorService.java:54) at com.exalate.node.util.concurrent.ClusteredSensitiveExecutorService.executeHandlingLocks(ClusteredSensitiveExecutorService.java:28) at com.exalate.replication.in.RequestWorker.run(RequestWorker.java:81) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: com.atlassian.jira.exception.CreateException: Error occurred while creating issue through workflow: at
    9. Sam

      sorry my mistake .. it is working

    CommentAdd your comment...