# Cannot create entry from a second-level collection

**URL:** <https://community.forestadmin.com/t/cannot-create-entry-from-a-second-level-collection/1634>\
**Category:** Help me!\
**Created:** [January 15, 2021, 2:07pm UTC](https://community.forestadmin.com/t/cannot-create-entry-from-a-second-level-collection/1634 "2021-01-15T14:07:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![XavierColombel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/xaviercolombel/32/106_2.png) [@XavierColombel](https://community.forestadmin.com/u/XavierColombel)\
**Post date:** [January 15, 2021, 2:07pm UTC](https://community.forestadmin.com/t/cannot-create-entry-from-a-second-level-collection/1634/1 "2021-01-15T14:07:42Z")

</div>

## Expected behavior

I need to create a new entry (funding) from a collection (leads).

In my lead, I choose `fundings` (Financements) on the left, then I create a new funding. In my form, I can also choose a funder. I’ve got an error in the console when I trigger the CRUD.

## Actual behavior

I’ve got this error when I click on `Create`:

![Capture d’écran 2021-01-15 à 14.56.03](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/d/ddf41870e8a542551b1866b43e2e591b1ad0e9f4.png)

 ![Capture d’écran 2021-01-15 à 14.56.28](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/c/c5c95459ac70c07fa1e1080515ed7f1f406ac735.png)

## Context

- Forest Express Mongoose Version: `^6.6.3`,
- Project Name: `lereacteur-admin`

---

<div class="post-metadata">

**Author:** ![anon34731316](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@anon34731316](https://community.forestadmin.com/u/anon34731316)\
**Post date:** [January 15, 2021, 2:43pm UTC](https://community.forestadmin.com/t/cannot-create-entry-from-a-second-level-collection/1634/2 "2021-01-15T14:43:31Z")

</div>

Hello @XavierColombel,

Thanks for contacting us!

Just to be sure, what you’re trying to achieve is to add an existing `funding` to a `lead` through the related data screen (looking like this screen just below)?

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/0/064fb4cbe33173236d8893537b10542ae88c31b4.png)

---

<div class="post-metadata">

**Author:** ![XavierColombel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/xaviercolombel/32/106_2.png) [@XavierColombel](https://community.forestadmin.com/u/XavierColombel)\
**Post date:** [January 15, 2021, 2:46pm UTC](https://community.forestadmin.com/t/cannot-create-entry-from-a-second-level-collection/1634/3 "2021-01-15T14:46:33Z")

</div>

No, I’m trying to add a new funding, from a lead.

---

<div class="post-metadata">

**Author:** ![XavierColombel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/xaviercolombel/32/106_2.png) [@XavierColombel](https://community.forestadmin.com/u/XavierColombel)\
**Post date:** [January 15, 2021, 4:45pm UTC](https://community.forestadmin.com/t/cannot-create-entry-from-a-second-level-collection/1634/4 "2021-01-15T16:45:47Z")

</div>

@anon34731316 did you fund any solution ? 😅

---

<div class="post-metadata">

**Author:** ![anon34731316](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@anon34731316](https://community.forestadmin.com/u/anon34731316)\
**Post date:** [January 15, 2021, 5:13pm UTC](https://community.forestadmin.com/t/cannot-create-entry-from-a-second-level-collection/1634/5 "2021-01-15T17:13:12Z")

</div>

@XavierColombel😅  
I understood what you were talking about, thanks!

But unfortunately I haven’t been able to reproduce it yet.

Can you show us the model definition of collections please?

---

<div class="post-metadata">

**Author:** ![XavierColombel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/xaviercolombel/32/106_2.png) [@XavierColombel](https://community.forestadmin.com/u/XavierColombel)\
**Post date:** [January 15, 2021, 5:25pm UTC](https://community.forestadmin.com/t/cannot-create-entry-from-a-second-level-collection/1634/6 "2021-01-15T17:25:17Z")

</div>

Fundings:

```json
const schema = mongoose.Schema(
  {
    funder: { type: mongoose.Schema.Types.ObjectId, ref: "Funders" },
    lead: { type: mongoose.Schema.Types.ObjectId, ref: "Leads" },
    documents: [{ type: mongoose.Schema.Types.ObjectId, ref: "Documents" }],
    gocardless: {
      paymentId: String,
    },
    externalReference: String,
    paymentMethod: String,
    paymentStatus: {
      type: String,
      default: "toClaim",
    },
    amount: Number,
    amountAlt: Number,
    vat: Number,
    currency: {
      type: String,
      default: "EUR",
    },
    discountType: {
      type: String,
      default: "none",
    },
    discountValue: Number,
    invoices: [{ type: mongoose.Schema.Types.ObjectId, ref: "Invoicing" }],
    credits: [{ type: mongoose.Schema.Types.ObjectId, ref: "Invoicing" }],
    incomings: [{ type: mongoose.Schema.Types.ObjectId, ref: "Incomings" }],
    refundPaymentId: String,
    chargeDate: Date,
    claimedAt: Date,
    createdAt: {
      type: Date,
      default: Date.now,
    },
    updatedAt: {
      type: Date,
      default: Date.now,
    },
  },
  {
    timestamps: false,
  },
);

module.exports = mongoose.model("Fundings", schema, "fundings");

```

Leads:

```json
const schema = mongoose.Schema(
  {
    unread: {
      type: Boolean,
      default: true,
    },
    email: String,
    telephone: String,
    firstname: String,
    lastname: String,
    companyName: String,
    birthDate: Date,
    address: String,
    zipCode: String,
    city: String,
    country: String,
    kairos: String,
    cpf: String,
    session: { type: mongoose.Schema.Types.ObjectId, ref: "SessionsApollo" },
    format: String,
    logicalTest: {
      candidate_id: String,
      link: String,
      score: Number,
      result: Object,
    },
    logicalTestStatus: {
      type: String,
      default: "unsent",
    },
    todolist: [Object],
    price: Number,
    currency: {
      type: String,
      default: "EUR",
    },
    infos: String,
    commentsArr: [
      { type: mongoose.Schema.Types.ObjectId, ref: "CommentsLeads" },
    ],
    students: [{ type: mongoose.Schema.Types.ObjectId, ref: "Students" }],
    fundings: [{ type: mongoose.Schema.Types.ObjectId, ref: "Fundings" }],
    funders: [{ type: mongoose.Schema.Types.ObjectId, ref: "Funders" }],
    quotes: [{ type: mongoose.Schema.Types.ObjectId, ref: "Invoicing" }],
    documents: [{ type: mongoose.Schema.Types.ObjectId, ref: "Documents" }],
    mailinglist: Boolean,
    utmSource: String,
    source: String,
    gclid: String,
    fbclid: String,
    referrer: String,
    marketing: {
      step: {
        type: Number,
        default: 0,
      },
      sentAt: {
        type: Date,
        default: Date.now,
      },
    },
    lastMailSent: Date,
    status: String,
    createdAt: {
      type: Date,
      default: Date.now,
    },
    updatedAt: {
      type: Date,
      default: Date.now,
    },
  },
  {
    timestamps: false,
  },
);

module.exports = mongoose.model("Leads", schema, "leads");

```

I have to say everything was working fine past days. I even rollback my commits and the problem is still the same… And I haven’t touch this collection and/or CRUD files.

---

<div class="post-metadata">

**Author:** ![Sharp](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/sharp/32/1694_2.png) [@Sharp](https://community.forestadmin.com/u/Sharp)\
**Post date:** [January 16, 2021, 8:47am UTC](https://community.forestadmin.com/t/cannot-create-entry-from-a-second-level-collection/1634/7 "2021-01-16T08:47:07Z")

</div>

Exactly same problem for me  
Everything was working for months and yesterday on the afternoon, impossible to create entity from related data creation form

Script crash on Forest side with a null referenceModel  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/8/8161a3805923e567d25967d7292df0c6f1cb8586.png)

Thanks for your help

---

<div class="post-metadata">

**Author:** ![XavierColombel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/xaviercolombel/32/106_2.png) [@XavierColombel](https://community.forestadmin.com/u/XavierColombel)\
**Post date:** [January 17, 2021, 5:22pm UTC](https://community.forestadmin.com/t/cannot-create-entry-from-a-second-level-collection/1634/8 "2021-01-17T17:22:30Z")

</div>

Forest Admin team has fixed the problem ! ✌
