Combing Fields

Case

Assume that the content to sync has a duration measured in hours, minutes, and seconds. i.e., A webinar or podcast. However, the source uses a different set of fields to track the duration than the destination. In this case the source is using multiple select fields as the duration values. But the destination is using a single text field with regex validation as the duration value.

source duration fields

destination duration field

We need to be able to:

  1. Combine 3 select fields into a text field

  2. Follow the regex validation of the destination text field

Solution

ImpulseSync can solve this with a single job and a combination of add-replace-field and regex manipulators.

First we create a job that syncs the content. In this job we'll start by adding an add-replace field manipulator.

This config will take the source fields webinar_section.duration.hours, webinar_section.duration.minutes, and webinar_section.duration.seconds and combine them into a single new string field webinar_group.duration.duration. It will combine the source hours, minutes, and seconds fields as follows: hours:minutes:seconds.

Now assuming all contents have values populated, this could be the end of the required configuration. However, in this case, not all the source contents had values populated. Or not all the source contents had a valid value selected. Meaning that the value is not a valid value for the destination regex.

To solve this we will add regex manipulators that will remove bad values with a valid default.

This config uses regex to check if the add-replace field value has the invalid format H:MM:SS. If it does have this invalid format, we add a leading 0 so the new value is 0H:MM:SS. Which is a valid format for our destination field.

This config uses regex to check if the source content actually had values for hours, minutes, and seconds or if the add-replace field manipulator did not set any field values. Which would leave the value as {{webinar_section.duration.hours}}:{{webinar_section.duration.minutes}}:{{webinar_section.duration.seconds}} which is the exact value set in the add-replace field manipulator. If that value exists, we then replace it with a valid default value of 00:00:00

When this job runs we can see that the destination content has valid values for duration.

Last updated