# Map Custom fields

**URL:** <https://community.exalate.com/t/map-custom-fields/4592>\
**Category:** General Questions\
**Tags:** usecase, customfields, migrated\_question, syncing, map-customfields\
**Created:** [November 4, 2024, 7:08am UTC](https://community.exalate.com/t/map-custom-fields/4592 "2024-11-04T07:08:40Z")\
**Posts on this page:** 2\
**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:08am UTC](https://community.exalate.com/t/map-custom-fields/4592/1 "2024-11-04T07:08:40Z")

</div>

_Originally asked by Madhu on 04 February 2021 [(original question)](https://oldcommunity.exalate.com/questions/25067694)_

* * *

My customer have custom field named “Sprint” with values 1 , 2 , 3 , 4.

We have custom field named “Test Sprint” with values Test1, Test2, Test3, Test4.

Customer is the Master, My “Test Sprint” field needs to updated based on Custom field “Sprint”.

1 - Test1

2 - Test2

3 - Test3

4 - Test4

Could you please suggest Outgoing and Incoming sync accordingly, Thanks.

* * *

---

<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:08am UTC](https://community.exalate.com/t/map-custom-fields/4592/2 "2024-11-04T07:08:41Z")

</div>

_Answer by André Leroy-Beaulieu Castro on 05 February 2021_

Hi Madhu,

Yes this should be possible with the following script, make sure you add this as an additional script to your Visual connection and make sure the part that says "executionInstanceName == “MyJira” " is changed to the name of the side where you want to set the Test Sprint custom field.

Script:

```auto
if (executionInstanceName == "MyJira") {
	def sprintMap = ["1":"Test1", "2":"Test2", "3":"Test3", "4":"Test4"]
	def remoteSprintValue = replica.customFields."Sprint".value
	issue.customFields."Test Sprint".value = sprintMap[remoteSprintValue]
}

```

Let me know how this goes!

Thanks,

André

* * *

#### Comments:

> **André Leroy-Beaulieu Castro commented on 08 February 2021**
>
> > Hey Madhu,
> 
> Ok, then it would be like this:
> 
> Outgoing Sync (Sending Side):
> 
> ```auto
> replica.customFields."Sprint" = issue.customFields."Sprint"
> 
> ```
> 
> Incoming Sync (Receiving side):
> 
> ```auto
> def sprintMap = ["1":"Test1", "2":"Test2", "3":"Test3", "4":"Test4"]
> def remoteSprintValue = replica.customFields."Sprint".value
> issue.customFields."Test Sprint".value = sprintMap[remoteSprintValue]
> 
> ```
> 
> Thanks,
> 
> André

> **André Leroy-Beaulieu Castro commented on 09 February 2021**
>
> > Hi Madhu,
> 
> Outgoing Sync:
> 
> ```auto
> replica.customFields."Dev Sprint" = issue.customFields."Dev Sprint"
> replica.customFields."Environment" = issue.customFields."Environment"
> 
> ```
> 
> Incoming Sync:
> 
> ```auto
> def sprintMap = ...
> def remoteSprintValue = ...
> issue.customFields."SIT Sprint"?.value = nodeHelper.getOption(issue, "SIT Sprint", sprintMap[remoteSprintValue])
> 
> def environmentMap = ...
> def remoteEnvironmentValue = ...
> issue.customFields."Phase"?.value = nodeHelper.getOption(issue, "Phase", environmentMap[remoteEnvironmentValue])
> 
> ```
> 
> The “…” just means you don’t have to change anything there _(old community)_
> 
> Let me know how this goes!
> 
> Thanks,
> 
> André

> **André Leroy-Beaulieu Castro commented on 09 February 2021**
>
> > Hey Madhu,
> 
> Well, I’m not completely clear on how your use case is, but the idea is that in the outgoing sync, the "issue.customFields.“Sprint” / “Dev Sprint” needs to match the name of the field that you are sending, so if the on the sending side the field is called “Sprint” then the line should be:
> 
> replica.customFields.“Dev Sprint” = issue.customFields.“Dev Sprint”
> 
> but if the field in the sending side is called “Sprint”, then the line should be:
> 
> replica.customFields.“Sprint” = issue.customFields.“Sprint”
> 
> and the same thing for the incoming sync, if the field in the incoming side is called “Dev Sprint”, then the line should be:
> 
> issue.customFields.“Dev Sprint”.value = …
> 
> etc.
> 
> Thanks,
> 
> André

> **Madhu commented on 10 February 2021**
>
> > Hi Andre,
> 
> We have 2 custom fields with different Lov’s and different field names, We want to map those fields.
> 
> Outgoing Sync will be same and I don’t have any queries for that.
> 
> “Dev Sprint” with values 1 , 2 , 3 , 4 .
> 
> “Test Sprint” with values Test1, Test2, Test3, Test4.
> 
> Mapping comes as follows,
> 
> 1 - Test1
> 
> 2 - Test2
> 
> 3 - Test3
> 
> 4 - Test4
> 
> Outgoing sync
> 
> **replica.customFields.“Dev Sprint” = issue.customFields.“Dev Sprint”**
> 
> Please suggest the incoming sync for this as we have different field names and different Lov’s.
> 
> We have to Ignore field values if there is no mapped value.
> 
> Thanks
> 
> Madhu

> **André Leroy-Beaulieu Castro commented on 12 February 2021**
>
> > Hey Madhu
> 
> It would be:
> 
> ```auto
> def sprintMap = ["1":"Test1","2":"Test2", "3":"Test3", "4":"Test4"]
> def remoteSprintValue = replica.customFields."Dev Sprint"?.value
> issue.customFields."Test Sprint"?.value = nodeHelper.getOption(issue, "Test Sprint", sprintMap[remoteSprintValue])
> 
> ```
> 
> Thanks,
> 
> André

> **André Leroy-Beaulieu Castro commented on 16 February 2021**
>
> > Hi Madhu,
> 
> If you know the names of the fields then just send the corresponding one on the sending side and and receive the corresponding one on the receiving side. I’m not answering more to this request as it’s clear enough with the answers above.
> 
> Thanks,
> 
> André
