Transactions

The following code snippets can be executed from the CSE console.

Entries

Entries can be retrieved in a number of different ways, e.g.:

const e1 = UM.getEntryByUid('some_uid'); const e2 = UM.getEntryByOid('1234567'); const e3 = UM.getEntry('login_name', 'admin'); UM.query('firstname="Max"').page(5).forEach( function(e) { } );

All manipulations of Entries are automatically collected in an implicit transaction, that needs to be committed in order for the changes to become persistent:

const e1 = UM.getEntryByOid('1234567'); e1.set('firstname', 'Bob'); const e2 = UM.addEntry(); e2.set('firstname', 'Jane'); UM.commitEntries();

If the commit failes for some reason, the whole transaction is rolled back and none of the changes will be persisted.

Sending transaction mails

Even sending transaction mails is part of this (two-phase) commit:

const e = UM.addEntry(); e.set('email', 'jane@localhost'); const n = e.notifications.add('newuser'); n.subject = 'This subject has been overridden...'; UM.commitEntries();

Other UM entities (Lists, Segments, Mailing Templates, …)

All other entities have a simpler API and – for the most part – require just one long line of code to create or update a perticular entity.

Example: Create update a List

Three different write modes:

  • UM.KEEP_EXISTING

  • UM.OVERWRITE_EXISTING

  • UM.FAIL_ON_EXISTING

Accordingly, the other types of entities can be created or updated:

  • UM.vchannels.add(...): Segments

  • UM.cronJobs.add(...): Cron Jobs

  • UM.pluginInstances.add(...): Plugin instances

  • UM.notifications.add(...): Mailing templates

  • UM.newsletterGroups.add(...): Newsletter groups