Skip to main content
Version: 8.1

Implement a standard module

Level: intermediate
Example

Create a standard module that contains the init() and render() methods. When loading the module, the client core must call the init() method, then the render() method. Each method must call a message box.

Create a visual module

  1. Open the Configuration section and select a custom package to add the schema.

  2. Click AddModule on the section list toolbar.

  3. Fill out the schema properties in the Module Designer.

    • Set Code to "UsrExampleStandardModule."
    • Set Title to "ExampleStandardModule."

    Click Apply to apply the changes.

  4. Add the source code in the Module Designer.

    UsrExampleStandardModule
    /* Declare a module called UsrExampleStandartModule. The module has no dependencies. Therefore, an empty array is passed as the second module parameter. The factory function returns a module object that has two methods. */ 
    define("UsrExampleStandardModule", [], function () {
    return {
    /* The client core calls this method first automatically when loading the module. */
    init: function () {
    alert("Calling the init() method of the UsrExampleStandardModule module");
    },
    /* The client core calls this method automatically when loading the module into a container. A link to the container is passed to the method as a renderTo parameter. The message box displays the ID of the page control that displays the visual module data. By default, centerPanel. */
    render: function (renderTo) {
    alert("Calling the render() method of the UsrExampleStandardModule module. The module is uploaded to the container " + renderTo.id);
    }
    };
    });
  5. Click Save on the Module Designer’s toolbar.

Outcome of the example

To view the outcome of the example, create the following request string.

[Creatio URL]/0/NUI/ViewModule.aspx#[SomeModuleName]

When loading the module, the client core must call the init() method, then the render() method. Each method calls a message box.

Call the init() method of the UsrExampleStandardModule module
Call the init() method of the UsrExampleStandardModule module
Call the render() method of the UsrExampleStandardModule module
Call the render() method of the UsrExampleStandardModule module

Resources

Package with example implementation