How to create an auto-linked entity in Rule?

With “normal” relations (i.e. not auto-linked), I can use the “Add new entity” Action to create and link a new entity in a Rule.

But when I change the relation to Automatically Link, that Action is no longer available.

Is there no way (besides script) to create a new related (auto-linked) entity?

For reference - this is how I solve the problem of creating auto-linked entities “on demand”.

In this example, the main DB is Contacts, and every Contacts entity should be auto-linked to a Meta Contacts entity sharing the same Name (there can be multiple Contacts entities with the same Name, and these all get linked to one Meta Contact entity).

The question is, how to automatically create new Meta Contacts entities when needed, so they can be auto-linked to matching Contacts entities? That is done by this Contacts rule:

//------------------------------------------------------------------------------------------------
// DB:      Contacts
// RULE:    Create Meta Contact
// WHEN:    Contacts Created, or Contacts Updated (Update, Name)
// ASSUMPTIONS:
//      Contacts has many-to-one relation 'Meta Contacts', which is auto-linked on Name = Name
//
// Create the associated Meta Contact (which will be auto-linked on the Name field)

const fibery = context.getService('fibery')

const THIS_TYPE   = args.currentEntities[0].Type
const SPACE       = THIS_TYPE.replace(/\/.*/, '')
const OTHER_TYPE  = SPACE + '/Meta Contacts'     // Other DB
const OTHER_FIELD = 'Name'                       // Auto-Linking field in other DB
const LINK_FIELD  = 'Name'                       // Auto-Linking field in this DB
for (const entity of args.currentEntities) {
    await fibery.createEntity(OTHER_TYPE, { [OTHER_FIELD]: entity[LINK_FIELD] })
}
3 Likes