How to trigger a custom command from the D2 Smartview Menu configuration

Once the Command event is defined, we should be able to trigger it from a menu using the "Publish event" action, with our custom event as a parameter.

While it can be configured, and the menu entry can appear in the REST response like this:

http://108.143.148.198:8180/D2-Smartview/repositories/repo/actions.json?type=MenuContext&widgetType=DoclistWidget&include-actions=PROMOTED&include-subtype=true&object-ids=090000018000bdd6

…         {
            "id": "menuContextCopyLink",
            "action": "D2-RunReport",
            "promoted": true,
            "actionParameters": {
              "message": "test"
            },
            "properties": {
              "name": "Run report,
              "toolTip": "Run report",
              "isDefault": false,
              "isDisabled": false,
              "shortcut": null,
              "menuType": "MenuContext",
              "subMenuType": null
            }
          },…

The custom action is not displayed in the UI.

The same action is properly displayed from a static toolbar defined in a widget.

Answers

  • @Loic HERVE : So inorder to have it as a menu item to display. it has to be created as a command and link the menu actions through node.action.rules.

    you can use the sample D2SV-ReadOnlyPermission-View for reference.

  • I have it configured as a custom command, set in node.action.rules, and I can display it with from my custom widget with a custom ToolItemsFactory.

    But when I try to use a D2 Smartview menu configuration to display my command on my custom type with the standard context menu in standard widgets, it does not show, although the REST service does return this item properly (as seen in the original question)

  • What might be the cause If the Sample plugin D2SV-ReadOnlyPermission-View throws an error like this?

  • I figured my issue about starting custom commands from the context menu: the command needs to be present in the menu loaded when D2-SmartView initialize (without object in the context) - so I needed either to side-load the menu entries in startup.js (like it is done in the D2-AdminGroups sample application) or to add the command (with the same menuId) in the menu loaded at startup.