1
0
-1
    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      The method I've used for some time (probably not the most elegant) is below:

      final def insightCustomFieldName = "nameOfInsightField"
      def insightKey = issue.customFields[insightCustomFieldName]?.value?.collect{
      		v ->
      		def cfm = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager()
      		def cf = cfm.getCustomFieldObject(issue.customFields[insightCustomFieldName].id)
      		def cft = cf.getCustomFieldType()
      		def vStr = cft.getStringFromSingularObject(v)
      		vStr
      	}
      if (insightKey != null) {
      	insightKey = insightKey[0]
      } else {
      	return
      }
      def objectSchemaId = 3 // This is the objectSchema you'll be searching for values (can be seen in URL when viewing schemas in Insight)
      Class iqlFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade");
      def iqlFacade = ComponentAccessor.getOSGiComponentInstanceOfType(iqlFacadeClass);
      /* Load objects with a specific value for a specified attribute */
      def IQL = 'Key = "'+insightKey+'" AND objectType = Users'
      int attributeRef= 499 // this is the ID of the attribute you want from the object selected in the field.
      def insightObject = iqlFacade.findObjectsByIQLAndSchema(objectSchemaId,IQL)
      /* If this is a mandatory field you should be able to do this: */
      if (insightObject != []) {
      	for (temp in insightObject [0].getObjectAttributeBeans()) {
      		if (temp.getObjectTypeAttributeId().equals(attributeRef)) {
      			replica.customKeys."SomeKey" = temp.getObjectAttributeValueBeans()[0].getTextValue()
      		} 
      	}
      }

      I think I've also used a way to search using attribute names but don't have that code on-hand.

      1. Patrick Mennecke

        Thanks, that works.

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

      Hi Patrick,


      It would be helpful if you can try sending a sync from side A to side B, then checking the Entity Sync Status on side B and looking at the “remote replica”? Here you can see how the Insight field is being sent, feel free to post it on this thread.


      Best regards,

      Ariel

      1. Patrick Mennecke

        That is the ougoing rule

        final def insightCustomFieldName = "IBM Server"
          
        replica.customKeys.
        "IBM Server" = issue.customFields"IBM Server"?.value?.collect{
        v ->
          def cfm = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager()
        def cf = cfm.getCustomFieldObject(issue.customFields[insightCustomFieldName].id)
        def cft = cf.getCustomFieldType()
        def vStr = cft.getStringFromSingularObject(v)
        vStr
        }
        
        


        with that i only send the Insight ID for example: CMDB-1027

      CommentAdd your comment...