PDX Channels Context Bind

The PDX Channels Context bind allows administrator to access information about PDX channels that can be added and removed within the Instrument UI. The bind allows users to write JavaScript business rules to return PDX channel IDs for the different methods relevant to this bind, such as channel IDs for added / removed channels and all channels for a product, even if syndication to PDX has not happened yet.

This PDX Channels Context bind only displays if the Product Data Exchange Syndication commercial license is enabled on your system. The bind can be found within the 'Binds to' dropdown as shown below:

Configuration

To use any bind:

  1. Create a business rule as defined in the Creating a Business Rule, Function, or Library topic.

  2. Edit the business rule as defined in the Editing a Business Rule or Function topic.

  3. In the Edit Operation dialog, add the bind to a business rule, as defined in the Adding a Bind topic in the Resource Materials online help documentation.

  4. In the Edit Operation dialog, optionally add Messages, as defined in the Localized Messages for JavaScript Business Rules topic.

  5. In the Edit Operation dialog, add JavaScript to call the bind.

Example

The following is an example JavaScript that uses this bind.

Important: 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.

The following is an example JavaScript that uses the PDX Channels Context bind. The JavaScript is executed when a user has added a node to a channel. It fetches the channel added to the node via the binding 'PDX Channels Context.'

Line 2 shows the code used to return the PDX channel IDs for the channels that have currently (just now) been selected for the product via the channel chooser in Instrument.

Copy
// Get the channels the user has selected in Instrument
const addedChannels = pdxChannelContext.getAddedChannels();
if (addedChannels == null || addedChannels.size() == 0) {
logger.info("No new added channels");
return;
}

logger.info("Added channels: " + addedChannels.size());

// Channels assigned to a node is set in a multi valued attribute.
// Get the values of the attribute and add the channels are not
// already assigned to the node.
const channels = node.getValue(channelList.getID());
const channelValues = channels.getValues();

var fireEvent = false;
for (var i=0; i<addedChannels.size(); i++) {
var newChannel = addedChannels.get(i) + "";
logger.info("Channel to add " + newChannel);

var add = true;
for (var j=0; j<channelValues.size(); j++) {
var currentChannel = channelValues.get(j).getSimpleValue() + "";
if (currentChannel === newChannel) {
// Channel already assigned, no need to assign it again
logger.info("New channel " + newChannel + " already contained in assigned channels");
add = false;
break;
}
}

if (add) {
logger.info("Adding new channel " + newChannel + " to assinged channels");
if (channelValues.size() == 0) {
channels.addValue(newChannel);
} else {
channels.addValue(newChannel);
}
fireEvent = true;
}
}

// If a new value was assigned to the node, fire an event on the node, so the
// node may be send to PDX via the Outbound Integration Point listening to this derived event
if (fireEvent) {
logger.info("Fire event on node");
pdxEventQueue.queueDerivedEvent(updateEvent, node);
} else {
logger.info("Channel attribute not updated");
}

The script stores the new channel(s) in a multi-valued attribute on the node and triggers a derived event. The derived event is used by an Outbound Integration Endpoint to trigger an export of the node to PDX.

For more information on additional methods, click the Technical Documentation button on the Start Page, and refer to the Javadoc link under the Extension API section.