Add starter rows to a new EspoCRM record with Ebla Link Pro using a guarded Custom field view that avoids duplicates during rerendering.
Some order, checklist, or service records should begin with a standard set of child rows. Ebla
Link Pro exposes createRelated for adding those rows to its inline collection before the parent
record is saved.
Requirements
This guide targets Ebla Link Pro 3.58 or later, which requires EspoCRM 9.3 or later and PHP 8.1 or later. You need administrator and filesystem access. Test the customization outside production first.
Example used in this guide
- Parent entity:
Order - Link Multiple field:
orderItems - Child entity:
OrderItem - Default child fields:
nameandprice
Replace these names with the internal names from your installation. Entity and field names are case-sensitive.
Step 1: Enable the Link Pro form
Open Administration → Entity Manager → Order → Fields → Order Items and configure:
- Enable Enable Form.
- Select the detail and edit layouts used by the inline rows.
- Enable Enable Add Row Button if users may add more rows.
- Save the field.
Add the Order Items field to the Order Detail and Edit layouts if it is not already present.

The Link Pro form and its inline layouts are configured on the Link Multiple field.
Step 2: Register a Custom field view
Set the field’s view in Custom entity metadata. If the file already exists, merge only the
orderItems.view value.
custom/Espo/Custom/Resources/metadata/entityDefs/Order.json
{
"fields": {
"orderItems": {
"view": "custom:views/order/fields/order-items"
}
}
}
Step 3: Add guarded starter rows
Create the field view below. The guard is essential because EspoCRM views can render more than once during a create session.
client/custom/src/views/order/fields/order-items.js
define(
'custom:views/order/fields/order-items',
['ebla-link-pro:views/fields/link-multiple-form'],
(LinkMultipleFormView) => class extends LinkMultipleFormView {
setup() {
super.setup();
this.defaultRowsAdded = false;
}
afterRender() {
super.afterRender();
if (
!this.model.isNew() ||
!this.form ||
['search', 'list'].includes(this.mode) ||
this.defaultRowsAdded ||
this.collection.length
) {
return;
}
this.defaultRowsAdded = true;
[
{
name: 'Standard service',
price: 100,
},
{
name: 'Implementation',
price: 250,
},
].forEach(row => this.createRelated(row));
}
}
);
The checks ensure that defaults are added only when:
- the parent is new;
- Link Pro is rendering its form mode;
- the view is not a list or search field;
- this view instance has not already added defaults;
- no rows are already present.
The last condition protects data restored by EspoCRM or entered before a rerender.
Step 4: Rebuild EspoCRM
Run Administration → Rebuild, then clear the browser cache if the previous JavaScript module is still loaded.
Test the behavior
- Create a new Order and confirm that exactly two rows appear.
- Change another field that causes the form to rerender and confirm that no duplicates appear.
- Remove a default row and confirm it is not inserted again during the same create session.
- Save the Order and reopen it; existing records must not receive new defaults.
- Open Order list and search views; the custom view must not add rows there.
- Confirm that users without create access to Order Items cannot bypass access controls.
Adapt the defaults safely
- Use valid internal field names from
OrderItem. - Do not embed real record IDs such as an assigned user or product ID in shared source code.
- When a row must point to an existing record, resolve it through controlled configuration or let the user select it.
- Keep calculated fields out of the default object when EspoCRM or Link Pro already calculates them.
Common problems
The rows appear more than once
Confirm that all guard conditions remain in place and that another customization is not calling
createRelated.
The view is not loaded
Check the namespace, filesystem path, and case of Order and orderItems, then run
Administration → Rebuild.
A value is missing
Confirm the child field’s internal name and that the field is enabled in the Link Pro edit layout.