The Sufficiency Check Action Context bind exposes methods to capture nodes, recipient mails, and channel ID data from the PDS Export Wizard for use in a business action. For more information, see the Publishing Only Sufficient Products to PDS topic in the Web User Interfaces / Web UI Getting Started documentation here.
Important: Testing this bind with the Test JavaScript button in the Edit Operation dialog results in error status. The error details include the text 'Cannot deliver bind of type SufficiencyCheckActionContext in this context.' Instead, run this business rule from code or within the UI.
The bind can be found within the 'Binds to' dropdown as shown below.
Configuration
To use any bind:
The bind exposes the following methods:
String getChannelID();
List<String> getRecipientMails();
List<Node> getNodes();
Example
The following is an example JavaScript that uses this bind.
Important: The example scripts should not be used as-is without thorough testing, including updating the script to match object and link types that exist on your system. Javascript variable names are case-sensitive.
When insufficientProductInCollectionAction and sufficientProductInCollectionAction actions are called, relevant arguments are passed to the context. The JavaScript example (shown in the image above
logger.info("########################################### INSUFFICIENT Business Action ##############################");
//Sufficiency Check Action Context exposed methods:
var nodes = context.getNodes();
var recipientMails = context.getRecipientMails();
var channelID = context.getChannelID();
logger.info("Insufficient nodes: " + nodes.size());
logger.info("ChannelID: " + channelID);
logger.info("Recipient mails: "+recipientMails);
if(nodes.size() == 0) {
logger.info("########################################### INSUFFICIENT Business Action STOPPED ##############################");
return;
}
var linkTypeHome = manager.getHome(com.stibo.core.domain.classificationproductlinktype.ClassificationProductLinkTypeHome);
var linkType = linkTypeHome.getLinkTypeByID("Default Classification Product Link Type");
logger.info("#### Creating contentOrderClassification...");
var contentOrderClassification = topClassification.createClassification(java.time.LocalDateTime.now(), "Classification 1 user-type root");
logger.info("#### Retreiving attributes...");
var channelIDAttr = manager.getAttributeHome().getAttributeByID("channelID");
logger.info("#### Setting values on classification...");
contentOrderClassification.setSimpleValue(channelIDAttr, channelID);
var recipientMails = context.getRecipientMails();
try {
var recipientMailsValue = contentOrderClassification.getValue("recipientMails");
for(i=0; i<recipientMails.size(); i++) {
recipientMailsValue.addValue(recipientMails.get(i));
}
} catch (e) {
logger.info("Error: " + e);
}
logger.info("#### Adding nodes to classification...");
for(i=0; i<nodes.size(); i++) {
contentOrderClassification.createClassificationProductLink(nodes.get(i), linkType);
}
logger.info("########################################### INSUFFICIENT Business Action FINISHED ##############################");
2020, Stibo Systems – Confidential