Jobs (CSE)
UM Cron Jobs can call custom CSE functions. In this example we will implement a function that performs a mass operation to remove all members of a given Segment from a given List.
Create a new file cmsbs-conf/cse/plugins/de.acme.tutorial/custom/removeSegmentFromList.mjs
:
de.acme.tutorial.removeSegmentFromList = (segmentName, listName) => {
const query = UM.query(`inChannel(${listName}) and inVChannel(${segmentName})`);
while (true) {
let entries = query.page(100, 0); // 100 per page, stay on page 0!
if (entries.length == 0) break;
entries.forEach(entry => {
entry.channels.unsubscribe(listName);
});
UM.commitEntries();
UM.test.emptyEntryCache();
}
}
See also Some gotchas.
Create and run the Demo Data job to generate some Lists, Segments and Entries.
Create a new CSE: Call job and enter the fully qualified name of the job function above as the function to be executed.
Related content
Callbacks (CSE)
Callbacks (CSE)
More like this
Automating Database Schema Updates (CSE)
Automating Database Schema Updates (CSE)
Read with this
Query UM entries using raw SQL
Query UM entries using raw SQL
More like this
Configuration and Customization
Configuration and Customization
More like this
Install Kickstarter
Install Kickstarter
Read with this
Manually adding additional attributes
Manually adding additional attributes
Read with this