Contentful logo

Contentful Community

Add references to an entry?

Hi! I have a model with a field type of references many.

So in each entry I can have a lot ot references, but I need to create a script to edit entries and be able to add references to that field, how can I do this ?

This is how I’m creating the model:
id: ‘object’,
name: ‘User Access Object’,
type: ‘Array’,
localized: false,
required: false,
validations: [],
disabled: false,
omitted: false,
items: {
type: ‘Link’,
validations: [],
linkType: ‘Entry’

But I don’t have a clue of how to update this model to add references, can anyone give me some idea of how to to this please ?

1 Like

Hi @yorchmx, which SDK are you using? :blush:

I’m using contentful-management

I’m creating an array of text types:

arrayOfGenerics : [ { sys:
     { space: [Object],
       id: '3dqKICQOuTHtvwVEWQzqYD',
       type: 'Entry',
       createdAt: '2019-08-05T17:25:03.711Z',
       updatedAt: '2019-08-05T17:25:04.021Z',
       environment: [Object],
       publishedVersion: 1,
       publishedAt: '2019-08-05T17:25:04.021Z',
       firstPublishedAt: '2019-08-05T17:25:04.021Z',
       createdBy: [Object],
       updatedBy: [Object],
       publishedCounter: 1,
       version: 2,
       publishedBy: [Object],
       contentType: [Object] },
    fields: { title: [Object] } },

Each element look like this, then I want to create an entry with that array in a one to Many field of my content type

const genericEntries = await environment.createEntry(, {
    fields: {
      title: {
        'en-US': 'Login page'
      genObject: {
        'en-US': arrayOfGenerics

Like that but I’m getting a lot of errors, any ideas ? I’m really starting to feel frustrated :frowning:

1 Like

Hey, I think this thread will help you to understand how to link entries to a parent entry: :blush:

1 Like