$object
Updated on Aug 29, 2025 9 minutes to readThe Object Plugin provides methods to create, read, update, delete, copy, and batch process objects based on metadata definitions.
Methods
| Method | Description |
|---|---|
| batchDelete | Deletes multiple objects at once, either by array of IDs or by object batch. |
| batchSave | Saves multiple objects at once, either by array or by object batch. |
| create | Creates a new object instance. |
| delete | Deletes a single object by its ID. |
| findById | Retrieves an object by its ID. |
| save | Saves changes to a single object. |
| saveJournalEntries | Saves multiple journal entries for the specified object. |
| updateAttributes | Updates rows using provided attribute values and optional conditions. |
| updateTabularSectionsAttributes | Updates tabular section rows without triggering object handlers. |
| updateCounters | Updates rows using provided counter changes and optional conditions. |
Methods Details
batchDelete()
• Type
// Overload 1: single script alias
(scriptAlias: E8ScriptAlias, ids: E8ObjectId[]) => void;
// Overload 2: multiple script aliases
(batch: object) => void;
• Details
Overload 1:
Expects a script alias and an array of record IDs.
Overload 2:
Expects a batch object containing multiple script aliases with their corresponding arrays of record IDs.
Deletes multiple objects.
Throws an IntegrityViolationError if deletion violates integrity constraints.
• Example
// --- Overload 1: Delete multiple records for a single script alias ---
E8App.$object.batchDelete('lstExample', ['101', '102', '103']);
// --- Overload 2: Delete records across multiple script aliases ---
E8App.$object.batchDelete({
lstExample: ['201', '202'],
lstAnotherExample: ['301', '302']
});
batchSave()
• Type
// Overload 1: single script alias
(scriptAlias: E8ScriptAlias, objects: object[]) => object;
// Overload 2: multiple script aliases
(batch: object) => object;
• Details
Overload 1:
Expects a script alias and an array of objects to save.
Overload 2:
Expects a batch object containing multiple script aliases with their corresponding arrays of record IDs.
Returns an array of saved objects.
• Example
// Example 1: Save multiple objects for a single script alias
const saved = E8App.$object.batchSave('lstExample', [
{ id: '123', name: 'Updated Name' },
{ name: 'New Record' }
]);
// Example 2: Save multiple objects across different script aliases (batch)
const savedBatch = E8App.$object.batchSave({
lstExample: [{ id: '456', name: 'Updated' }, { name: 'Another' }],
lstAnotherExample: [{ id: '789', title: 'Updated Title' }]
});
create()
• Type
(scriptAlias: E8ScriptAlias) => object
• Details
Expects a script alias of the object type.
Returns the newly created object.
delete()
• Type
(scriptAlias: E8ScriptAlias, id: E8ObjectId) => void
• Details
Expects a script alias and a record ID.
Deletes the specified object.
Throws IntegrityViolationError if deletion violates integrity constraints.
findById()
• Type
(scriptAlias: E8ScriptAlias, id: E8ObjectId) => object | false
• Details
Expects a script alias and a record ID.
Returns the object if found, otherwise false.
save()
• Type
(scriptAlias: E8ScriptAlias, object: object) => object
• Details
Expects a script alias and an object to save.
Returns the saved object.
saveJournalEntries()
• Type
(
scriptAlias: E8ScriptAlias,
id: E8ObjectId,
journalScriptAlias: E8ScriptAlias,
entries: object[]
) => void
• Details
Expects:
• a script alias of the parent object type,
• a record ID of the parent object,
• a script alias of the journal entry type,
• an array of journal entry objects.
Each entry in entries must be an object where:
• the key is the journal attribute script alias,
• the value is the value to be stored for that attribute.
Saves multiple journal entries for the specified object.
• Example
// Save sales journal entries for Sales invoice
E8App.$object.saveJournalEntries(
'lstSalesInvoice',
123,
'jnlSales',
[
{
date: '2026-03-13',
product: 101,
quantity: 2,
unitPrice: 100,
totalAmount: 200
},
{
date: '2026-03-14',
product: 205,
quantity: 5,
unitPrice: 30,
totalAmount: 150
},
]
)
updateAttributes()
• Type
(
scriptAlias: E8ScriptAlias,
object: object,
conditions?: Conditions
) => number
• Details
Expects a script alias, an object containing attribute values to update, and optional Conditions to filter which rows to update.
⚠️ If you do not specify any condition, this method will update all rows in the table.
Returns the number of rows updated.
• Example
const updatedCount = E8App.$object.updateAttributes('lstExample', { status: 'Active' }, { id: '123' });
// updatedCount contains number of rows updated
updateTabularSectionsAttributes()
• Type
(
scriptAlias: E8ScriptAlias,
object: object,
conditions?: Conditions
) => number
• Details
Expects a script alias of the tabular section type, an object containing attribute values to update, and optional Conditions to filter which rows to update.
Conditions support filtering by owner attributes using dot notation, for example, { 'owner_id.client': '123' }.
Updates tabular section attributes directly without triggering object handlers.
⚠️ If you do not specify any condition, this method will update all rows in the tabular section table.
Returns the number of rows updated.
• Example
const updatedCount = E8App.$object.updateTabularSectionsAttributes(
'tbsExample',
{ status: 'Processed' },
{ 'owner_id.client': '123' }
);
// updatedCount contains number of rows updated
updateCounters()
• Type
(
scriptAlias: E8ScriptAlias,
object: object,
conditions?: Conditions
) => number
• Details
Expects a script alias, an object containing counter changes to apply, and optional Conditions to filter which rows to update.
⚠️ If you do not specify any condition, this method will update all rows in the table.
Returns the number of rows updated.
• Example
const updatedCount = E8App.$object.updateCounters('lstExample', { visits: 1 }, { status: 'Active' });
// updatedCount contains number of rows updated