# Sync insight customfields

**URL:** <https://community.exalate.com/t/sync-insight-customfields/4600>\
**Category:** General Questions\
**Tags:** exalate, usecase, migrated\_question, insight, ariel\
**Created:** [November 4, 2024, 7:09am UTC](https://community.exalate.com/t/sync-insight-customfields/4600 "2024-11-04T07:09:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 7:09am UTC](https://community.exalate.com/t/sync-insight-customfields/4600/1 "2024-11-04T07:09:19Z")

</div>

_Originally asked by Patrick Mennecke on 12 February 2021 [(original question)](https://oldcommunity.exalate.com/questions/25068111)_

* * *

How can i send object attributes for example name?

With this [https://docs.idalko.com/exalate/display/ED/How+to+sync+Insight+custom+fields](https://docs.idalko.com/exalate/display/ED/How+to+sync+Insight+custom+fields) i only send the id.

* * *

---

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 7:09am UTC](https://community.exalate.com/t/sync-insight-customfields/4600/2 "2024-11-04T07:09:20Z")

</div>

_Answer by Jonathon Irwin on 22 February 2021_

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

```auto
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.

* * *

#### Comments:

> **Patrick Mennecke commented on 24 February 2021**
>
> > Thanks, that works.

---

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 7:09am UTC](https://community.exalate.com/t/sync-insight-customfields/4600/3 "2024-11-04T07:09:21Z")

</div>

_Answer by Ariel Aguilar on 16 February 2021_

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

* * *

#### Comments:

> **Patrick Mennecke commented on 16 February 2021**
>
> > That is the ougoing rule
> 
> ```auto
> 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

---

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 6, 2024, 7:09am UTC](https://community.exalate.com/t/sync-insight-customfields/4600/4 "2024-11-06T07:09:31Z")

</div>

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