LoadTaskConfiguration.ds

Note: This code is provided as a sample. It isn't a supported part of the SiteGenesis application.
/**
 * Loads the configuration for the given task name from a custom object.
 *
 * @input TaskName  : String    Name of the configuration
 * @input sampleLogger  : Object    Sample logger input for Sample logger
 * @output TaskConfiguration  : dw.object.CustomObject    Configuration for the task
 * @output sampleLogger  : Object    Sample logger debug output for Sample logger
 * @output sampleError  : Object    Sample error output for Sample logger */
importPackage(dw.system);
importPackage(dw.object);

// Sample Logging ImportScript
importScript("bc_sample:library/common/libContext.ds");
importScript("bc_sample:library/utility/exception/libsampleException.ds");
importScript("bc_sample:library/utility/logging/libLog.ds");

var CUSTOM_OBJECT_NAME = "TASK_CONFIGURATION";

function execute(pdict: PipelineDictionary): Number {
    // Sample Logging var
    var _context: String = new Context("LoadTaskConfiguration.ds");
    var _logger: Log = Log.getLogger(pdict);

    var taskName: String = pdict.TaskName;

    try {
        var taskConfiguration: CustomObject = CustomObjectMgr.getCustomObject(CUSTOM_OBJECT_NAME, taskName);

        _logger.debug(_context, "Loaded task configuration '" + taskName + "'");

        pdict.TaskConfiguration = taskConfiguration;
    } catch (e) {
        // sample Logging wrap error into custom exception
        var exception: sampleException = new sampleException(_context, "Error occurred calling Task configuration ", e);



        // sample Logging call into error handler
        _logger.error(_context, "Error occurred calling Task configuration " + exception);
        pdict.sampleError = exception;



        return PIPELET_ERROR;
    }
    return PIPELET_NEXT;
}
X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.