HELP!

Build Tool Script Example

The following is the source of the script used for the Add a Dialog Build Tool:

// @type: wizzard
// @title: Add a Dialog
// @description: Add a Dialog
// @menu_description: Add a Dialog
// @group: Basic Tools
// @submenu: Add a New User Interface Object...
// @importance: 105
// @contexts: ["tree", "explorer", "treebuild"]
// @deployments: ["interactive", "chat"]
// @style: background-color: #f2711c; border-style: solid; border-color: #f49a5f; border-width: medium; color: #000000;
// @catalog_style: true
wizzards.register({
    "help": "https://viablhelp.xpertrule.com:30001/reference_guide/decision_factory_basics/using_the_build_tools/basic_tools/dialog",
    "pages": [
        {
            "name": "name_page",
            "elements": [
                {
                    "type": "text",
                    "name": "objectName",
                    "prompt": "Please supply a name for your new dialog",
                    "default": "OBJECT_NAME",
                    "placeholder": "Dialog name"
                },
                {
                    "type": "text",
                    "name": "description",
                    "prompt": "Dialog Description",
                    "placeholder": "Optional dialog description",
                    "optional": true,
                    "footer": "n.b. The description can be shown on decision trees via the 'Show Object Descriptions' in the 'Knowledge Base' section of the 'Knowledge Base Setting' dialog"
                },
                {
                    "type": "dropdown",
                    "name": "catName",
                    "prompt": "Create in Catalog Category",
                    "empty": "No category",
                    "optional": true,
                    "autofill": "categories",
                    "default": "Dialogs & Reports"
                }
            ]
        },
        {
            "name": "parent_page",
            "style": {
                "overflow": "hidden",
                "display": "flex",
                "flex-direction": "column"
            },
            "elements": [
                {
                    "type": "objectlist",
                    "name": "parentObject",
                    "prompt": "Does this dialog have a parent?",
                    "empty": "No parent",
                    "optional": true,
                    "multisel": false,
                    "style": {
                        "flex": "1 0"
                    },
                    "allow": function(aObject) {
                        return (aObject.aType == TYPE_DIALOG) && !aObject.aDefinition.pid; // callback to determine whether to include a specific object in the list
                    },
                    "searchable": true,
                    "footer": "Child dialogs contain all the elements of the parent dialog and include thier own items in the parent's <b>container</b> control"
                }
            ]
        }
    ],
    "start_page": "name_page",
    "next": function(currentPage, wizards, data, initialShow, context, completeCB) {
        switch (currentPage) {
            case "name_page":
                if (initialShow) {
                    data.objectName = ""; // override the default name with empty
                }
                if (context.depTargets.length == 1 && context.depTargets[0] == "chat") {
                    completeCB("DONE"); // chat only = no parenting
                } else {
                    completeCB("parent_page");
                }
                break;
            case "parent_page":
                completeCB("DONE");
                break;
        }
    },
    "done": function(wizards, data, completeCB, context) {
        // create dialog object (cat -1 = orphaned)
        var catID = data.catName === "" ? -1 : parseInt(data.catName, 10);
        if (!wizards.creationObjectAsync({name: data.objectName, baseclass: -TYPE_DIALOG, catID: catID, dlgParent: data.parentObject ? data.parentObject : 0})) {
            return;
        }
        wizards.performAsyncObjectCreation(function(list) {
            var newID = list[data.objectName];
            if (data.description) {
                let o = _dgo(newID);
                o.aDefinition.description = data.description;
                o.loadedDefinition.description = data.description;
            }
            wizards.setObjectStyle(newID, context.definition);
            completeCB(newID, null, true);
        });
    }
});

On This Page