How to synchronise the Team field from Portfolio for Jira

Originally asked by Amr Hamza on 08 July 2020 (original question)


We are syncing two Jira Server instances and we have two scenarios here:
1. Portfolio Team fields on both instances
2. Portfolio Team field on one side and a single select list on the other
Your support is very much appreciated.Quelle: Feature - Custom field sync (old community)


Answer by Berry Kersten on 04 December 2020

Just found the solution!

It’s

Outgoing sync

replica.customFields."Team" = issue.customFields."Team"

Incoming sync

if(replica.customFields."Team".value) {
  issue.customFields."Team".value = replica.customFields."Team".value?.description?.title?.toString().replace("\"", "");
}
  


Comments:

Francis Martens (Exalate) commented on 04 December 2020

ah - ok - nice

Answer by Francis Martens (Exalate) on 08 July 2020

Hello Amr Hamza

Can you confirm my rewording of your question

  1. Portfolio team bidirectional sync.
    Blue Jira and Red Jira have both Portfolio
    1. The teams are identical, and changing the team on Blue, will change it on Red
    2. The teams are not identical, and changing the team on Blue to a non existing team on Red will create the team on Red
  2. Portfolio team sync to a select list
    1. The selected blue team is setting the corresponding value in the red select list
    2. New blue teams lead to new entries in red

Comments:

Amr Hamza commented on 09 July 2020

Hello Francis Martens (Exalate) ,

Thanks for your reply.

  1. yes bidirectional
    1. exactly like that
    2. if the teams are not identical, it would be greate if we can map them and set a default value to fall back to in case of no match.
  2. also bidirctional (Blue Jira has Portfolio Team field, Red Jira has a single select field)
    1. Red selects an option in the field → Exalate sets the corresponding team in Blue.
    2. Blue selects a team in Portfolio → Exalate sets the corresponding option in the field in Red.
    3. The same idea with the mapping and the default value if no match was found.
Francis Martens (Exalate) commented on 09 July 2020

The first part is simple - in the outgoing sync of the connection add following statement

replica.customFields.Team = issue.customFields.Team

When a sync is happening the other side will receive

replica.customFiels.Team.description.title should contain the name of the team.

Applying to a select list is straightforward by using the getOption approach.

We are looking how to set the team field, it needs to go through the Portfolio/Advanced Roadmap api.
But this approach should already cover part 2 of the question

Amr Hamza commented on 09 July 2020

Thanks Francis Martens (Exalate) .

Agreed. I suppose the obstacle here is how to set the Portfolio Team field in the incoming sync rules.

Amr Hamza commented on 21 July 2020

Hi Francis Martens (Exalate).

I hope you’re well. Just wanted to check, if there is any progress here.

Thanks.

Cheers,

Amr

Amr Hamza commented on 05 August 2020

Hello Francis Martens (Exalate),

Are there any updates on this question?

Thanks.

Cheers,

Amr

Berry Kersten commented on 16 November 2020

hi Francis Martens (Exalate), I have an almost similar use case, except I just want to show the Team Name on the remote side.

I have created a new custom field (single text line) Team, and now it shows {“id”:1,“description”:{“title”:“Team A”,“avatarUrl”:{},“shareable”:true}}

So, I suppose I have to trim this so that only Team A will be shown. Any idea how to do this kind of trimming? Thanks.

Francis Martens (Exalate) commented on 16 November 2020

Can you try

replica.customFields.Team = issue.customFields.Team?.description?.title

And let us know

Berry Kersten commented on 16 November 2020

Thanks.

In that case, I’m getting an Cannot get property ‘value’ on null object

Outgoing sync:

replica.customFields.Team = issue.customFields.Team?.description?.title

Incoming sync:

issue.customFields.“Team”.value = replica.customFields.“Team”.value

In remote issues I see:
Team (11001): {“id”:3,“description”:{“title”:“Team IDE (C)”,“avatarUrl”:{},“shareable”:true}}

Francis Martens (Exalate) commented on 16 November 2020

Berry

Ah - I made a typo - better would be

replica.customKeys.Teamtitle = issue.customFields.Team?.description?.title

and on the incoming …

issue.customFields."Team".value = replica.customKeys.Teamtitle
Berry Kersten commented on 17 November 2020

Hmm, in that case no information is being synced: in remote issues there’s no Custom Keys Teamtitle present.

It looks like it does not get the exact data within {“id”:3,“description”:{“title”:“Team IDE (C)”,“avatarUrl”:{},“shareable”:true}}

Francis Martens (Exalate) commented on 17 November 2020

Can you check what the value is of issue.customFields.Team?.description?.title by adding

throw new Exception("Title = ${issue.customFields.Team?.description?.title}")

in the outgoing sync. It should clarify if you get some information out of that customfield

Berry Kersten commented on 18 November 2020

Sure, then I’m getting com.exalate.api.exception.script.ChangeProcessorException: Script error for issue RI-5024. Details: No such property: title for class: java.lang.String.

Francis Martens (Exalate) commented on 18 November 2020

(old community)
You will have to do some investigations.
Can you try

throw new Exception("Title = ${issue.customFields.Team.value?.description?.title}")

Berry Kersten commented on 23 November 2020

Francis Martens (Exalate) Sure, in that case it returns: Details: Title = null.

Francis Martens (Exalate) commented on 04 December 2020

In an earlier comment you indicated

I have created a new custom field (single text line) Team, and now it shows {“id”:1,“description”:{“title”:“Team A”,“avatarUrl”:{},“shareable”:true}}

Where did you fetch this value?

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