JSON object to reference
Last updated
Last updated
Assume there is a field that has a JSON object as the value which contains the ID of a related asset. We want to migrate both the asset and the content. But the content needs a proper relationship/reference field to the asset, instead of a JSON object.
We need to be able to:
Migrate the asset
Migrate the content
Convert a JSON object with data into a relationship field
First setup both the asset job and the content job.
In this example, the asset job is a standard with no manipulators or mappings. And the source connector is drupal7 so the contentype is set to "IMPULSE_ASSET"
The second job does have a mapping and manipulators as appropriate to migrate the content. In this example we'll be looking specifically at using the liquid manipulator.
The JSON object has an attribute fid
this is the ID of the content from the source system, but the drupal7 connector combines both the content type and the ID of the content for ID Maps. So, we need to format the ID value as appropriate for the system before using the idMap
filter.
Once the jobs are configured, you can run the asset job to migrate the dependent asset. Then run the content job to migrate the content and have a relationship field referencing the asset.
ImpulseSync can do this using the and the .
The liquid template uses the to parse out the fid value. And the to clean up the value as necessary by removing the brackets around the value. Then it prepends the content type for the job "IMPULSE_ASSET". Once the formatted ID value is obtained, the idMap
filter can be used. The ID map path is set to "content.id" and the source and destination content types are set as "IMPULSE_ASSET" based on the source content type set in the asset job, and the fact that there was no mapping for that job. (If there was a mapping for the job, the destination content type would match the mapped content type.) The returned ID map value is then captured in a variable.
Since the template has the proper destination ID value, we can use the liquid template to to sync. Setting the assetId
variable as the value for the childId
. Be sure to set the optional config option "Impulse Field Value" for the liquid manipulator to impulseValue
. This way the manipulator knows the liquid template is actually a full field, and not just a value of a field.