Simple Migration - Help Needed

Hey all, first time poster, please forgive me if I get some of the terminology wrong :slight_smile:

We have a data model that looks like this (forgive some of the field names, I changed their actual names vs. what we’re using):

embeddedObj : Object (contains fields: uuid, title)
someOtherField: Short text
uuid: Short text

I have a migration I’m attempting to set up, but I keep getting that the field is undefined. Essentially we have added a new field uuid at the top level of our model. We would like to copy the value of the UUID in the embedded object and update the uuid field at the top level. Here’s what the migration script looks like:

   module.exports = function (migration) {
                contentType: 'myContentType',
                from: ['embeddedObj'],
                to: ['uuid'],
                transformEntryForLocale: function (fromFields, currentLocale) {
                        const obj = fromFields.embeddedObj[currentLocale];
                        return { uuid: obj.uuid };

This is the error I’m getting:

TypeError: Cannot read property ‘en-US’ of undefined

I gather that’s because fromFields.embeddedObj is undefined. I’m not entirely sure what I’m doing wrong. Can anyone offer any thoughts on what I can try? FWIW I also tried copying from someOtherField to uuid (at the top level) and was getting the same error.

Thanks in advance!

Hi @will.taylor, when you say embeddedObj, do you mean a Linked Entry? Or might be somehow an entry included inside a Rich Text field?

TypeError: Cannot read property ‘az’ of undefined
at EntryTransformAction.transformEntryForLocale (/Users/imrkhan2/IdeaProjects/bitbucket/f2-f3-contentful/migrations/R3.0.7/GPSEWEAS-696-non-prod-domian-change-for-MP4URL.js:46:50)
at EntryTransformAction.applyTo (/usr/local/lib/node_modules/contentful-cli/node_modules/contentful-migration/built/lib/action/entry-transform.js:47:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async IntentList.applyTo (/usr/local/lib/node_modules/contentful-cli/node_modules/contentful-migration/built/lib/intent-list/index.js:87:21)
at async migration (/usr/local/lib/node_modules/contentful-cli/node_modules/contentful-migration/built/lib/migration-parser.js:148:9)
at async run (/usr/local/lib/node_modules/contentful-cli/node_modules/contentful-migration/built/bin/cli.js:112:23)