Skip to main content

IEntityCommand

By implementing this interface, you can define custom commands for an object or a ticket. For an example, see the CostsCalculation application template.

In the application, create a new script using the IEntityCommand template and name it appropriately according to the functionality of the custom command. In the newly created script, set the following properties in the constructor of the class:

  • Id - a unique command identifier ( string)
  • Entity - the type of entity for which the command will be displayed (Entity.Ticket or Entity.Object).

Interface methods

MethodDescription
ShowDisplay the command in the command menus.
RunRun the command.

Show

This method controls display of the command in command menus.

Syntax:

 EntityCommandShowResult Show(int entityId, int personId)

Parameters:

  • entityId - the entity ID (tblNode.intNodeId or tHdTicket.iHdTicketId) for which the command should be displayed.
  • personId - the ID of the user (tPerson.iPersonId) to whom the command should be displayed.

Return values:

An instance of the class EntityCommandShowResult with properties:

  • Name (string) - a display name of the command
  • Show (bool) - true = the command will be displayed, false = the command will not be displayed.
  • Position (int) - the position in UI at which the command will be displayed:
    • 1 = first position of the entity main menu
    • 2 = last position of the entity main menu
    • 3 = first position of the nested menu in the entity main menu
    • 4 = last position of the nested menu in the entity main menu
  • Icon (string) - a command icon name; Use the Microsoft fluent library viewer with “20 Regular” filter on. After finding the most suitable icon, copy its name without “fluent:” and replace “-“ characters with “_”.
    • Example: The icon fluent:edit-20-regular use in your code as edit_20_regular.
tip

By calling this method in the Run method, you can check if the conditions for displaying the command haven't changed between the time of displaying the command and running it.

Run

This method implements the command itself.

Syntax:

CommandResult Run(int entityId, int personId);

Parameters:

  • entityId - the entity ID (tblNode.intNodeId or tHdTicket.iHdTicketId) for which the command was run.
  • personId - the user ID (tPerson.iPersonId) who ran the command.

Return values:

An instance of the CommandResult class containing properties:

  • MessageType (MessageType) - specify whether a message should be displayed to the user as a result of the command execution:
    • None – no message will be displayed
    • Info - an information message will be displayed
    • Warning - a warning message will be displayed
    • Error - an error message will be displayed
  • MessageText (string) - specify a text of the message that will be displayed to the user.
  • NavigateToUrl (string) - optionally specify an URL to navigate to after the command execution.
tip

If the custom command is to open another Alvao WebApp page, use the Alvao.API.Common.DbProperty.WebAppUrl property from the Alvao.API to get the root URL of the WebApp.