Create a recipient
var recipient = { xtkschema: "nms:recipient", _operation: "insert", firstName: "Thomas", lastName: "Jordy", email: "jordy@adobe.com" }; await NLWS.xtkSession.write(recipient);
Create multiple recipients
var recipients = { xtkschema: "nms:recipient", recipient: [ { _operation: "insert", firstName: "Christophe", lastName: "Protat", email: "protat@adobe.com" }, { _operation: "insert", firstName: "Eric", lastName: "Perrin", email: "perrin@adobe.com" } ] }; await NLWS.xtkSession.writeCollection(recipients);
List all recipients in Adobe
var queryDef = { schema: "nms:recipient", operation: "select", select: { node: [ { expr: "@id" }, { expr: "@firstName" }, { expr: "@lastName" }, { expr: "@email" } ] }, where: { condition: [ { expr: "GetEmailDomain(@email)='adobe.com'" } ] } } const query = NLWS.xtkQueryDef.create(queryDef); var recipients = await query.executeQuery(); console.log(JSON.stringify(recipients));
Count total number of profiles
var queryDef = { schema: "nms:recipient", operation: "count" } var query = NLWS.xtkQueryDef.create(queryDef); var count = await query.executeQuery(); count = XtkCaster.asLong(count.count); console.log(count);
Update a profile. In this case, use the "@email" attribute as a key. If the `@_key` attribute is not specified, the primary key will be used.
var recipient = { xtkschema: "nms:recipient", _key: "@email", _operation: "update", firstName: "Alexandre", email: "amorin@adobe.com" }; await NLWS.xtkSession.write(recipient);
Delete a profile
var recipient = { xtkschema: "nms:recipient", _key: "@email", _operation: "delete", email: "amorin@adobe.com" }; await NLWS.xtkSession.write(recipient);
Delete a set of profiles, based on condition. For instance delete everyone having an email address in adobe.com domain
await NLWS.xtkSession.deleteCollection("nms:recipient", { condition: { expr: "GetEmailDomain(@email)='adobe.com'"} });