Create extra entities after create one entry

Thanks @Shekhar for pointing me in the right direction!

I added a new file under api/{name}/content-types/{type-name}/lifecycles.ts

export default {
  async afterCreate(event) {
    const { result, params } = event;
    await strapi.entityService.create(
      "api::another-type.another-type",
      {
        data : { 
          Relation: [result["id"]] // This is how I link the sub-entries with the main entry.
        }
      });
  }
}
1 Like