Answer by Francis Martens (Exalate) on 12 October 2023
We are experimenting with a customised Chatgpt chatbot - check out the details
I would like to split the value of the Insight Field over the Select List (cascading field).For example the value of my Insight Field is HelloThere, when it syncs over to the other instance, I would like Hello to be the first value in the select list, and There to be the second value in the select list.Is this possible? What would the groovy look like for that?Much appreciated.
Yes, it is indeed possible to split the value of your Insight Field over to a Select List (cascading field) in Jira Cloud. For instance, given that the value is āHelloThereā and you want to split it so āHelloā becomes the parent and āThereā becomes a child option, you will need to configure both the Outgoing and Incoming sync as follows:
- First, configure the Outgoing sync to send your Insight field value:
replica.customFields."InsightField" = issue.customFields."InsightField"
2. Afterward, in the Incoming sync, you should extract the value from your Insight Field and form the parent-child select list values:
def insightFieldValue = replica.customFields."InsightField".value
def splitValues = insightFieldValue.split("(?<=Hello)")
def parent = nodeHelper.getOption(issue, "Cascading select", splitValues[0])
issue.customFields."Cascading select".value = nodeHelper.getCascadingSelect(parent, parent.childOptions.find{it.value == splitValues[1]})
Note: In the split function, replace āHelloā with the actual parent value you expect in your use case.
Make sure to replace āInsightFieldā and āCascading selectā with the actual field names in your case.
This script will first split the Insight Field value into two parts based on your delimiter (āHelloā in this case). Then it retrieves the parent option and combines it with the child option to form the cascading select field value at the destination side.
*Remember to check the sync scope and ensure you have permissions to access the custom fields. Also, the āparent.childOptions.findā function expects the child option to exist; you might want to extend this script to handle the scenario when the child option doesnāt exist.
Find further details on handling custom fields sync in the Exalate documentation: https://docs.exalate.com/docs/how-to-sync-cascading-select-custom-fields-in-jira-cloud
The insightfield has a structure and it is not necessarily āvalueā that contains the value
Indeed, an Insight custom field has a specific structure, which is not a simple āvalueā but rather a set of items (objects) and attributes.
The synchronization of Insight fields is done by assigning the string representation of the Insight object to a custom field on the replica. The same process applies on the destination side where we set the value of an Insight custom field equal to the value coming from the source.
Hereās an example of how to set a single Insight object to a target Insight custom field:
Outgoing from Source Side:
if(issue.customFields."Insight Field Name".value != null){
replica.customFields."Insight Field Name" = issue.customFields."Insight Field Name".value.inspect()
}
Incoming to Destination Side:
(note that that class is only valid on Jira On Premise)
issue.customFields."Insight Field Name".value = com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade.loadObjectBean(replica.customFields."Insight Field Name".value)
I should mention that the example I have given you here is a basic setup that only considers the primary object of the Insight field. If you have several objects or want to extract values from your Insight objectās attributes or references, you will need to adapt your script accordingly.
Please check the Exalate documentation for more guidance on how to sync Insight custom fields: https://docs.exalate.com/docs/how-to-sync-insight-custom-fields
Comments:
Francis Martens (Exalate) commented on 12 October 2023
This is an example of a response from a finetuned Chatgpt trained on the documentation of Exalate.
Samuel Carter commented on 16 October 2023
Thanks Francis Martens (Exalate) Iāll give this a go.