Skip Navigation LinksALVAO 10.0ALVAO Service DeskSystem Implementation in an OrganizationCustom Edits and ExtensionsCustom Program ExtensionsCustom CommandsCustom Main Menu Commands Skip Navigation Links. Skip Navigation Links Skip Navigation Links.


Custom Main Menu Commands

By placing a command in the main menu you can make frequently used pages and operations not linked to specific requests in ALVAO Service Desk accessible to users.

The commands will be displayed in the main menu of the Service Desk Console and of ALVAO WebApp.

Tip:
To replace a system command/link in the ALVAO WebApp main menu with a custom one, hide the system command/link.

Creating a new command

In the folder where ALVAO Service Desk WebService is installed, copy the CodeExtension_Template.cs file in the App_Code folder and rename it according to the functionality of the custom command.

In the newly created file, enter a definition of the new command into the bordered code block by implementing the IGeneralCommand interface and set the values for the id, name, and position properties in the command class constructor.

  • id – command number (unique)
  • name – command name displayed in the applications
  • position – position at which the command will be displayed in the applications
    • 1 = on the first place of the application main menu
    • 2 = on the last place of the application main menu
    • 3 = on the first place of the user menu in the application main menu
    • 4 = on the last place of the user menu in the application main menu

Example:


class Command1 : IGeneralCommand
{
    CommandDesc commandDesc;

    public CommandDesc CommandDesc
    {
        get { return commandDesc; }
        set { commandDesc = value; }
    }

    public Command1()
    {
        int id = 1;
        string name = "Report problem";
        int position = 1;

        commandDesc = new CommandDesc(id, name, position);
    }
}

Defining conditions for displaying the command

In the command class created, implement the Show method from the IGeneralCommand interface. The input parameter personId contains the id of the person the command should be displayed to.

The output is a truth value representing whether the command should be displayed to the user in the application main menu or not.

Tip:
By calling this method in the Run(…) method, you can check before running the command whether the conditions for its displaying changed in the period between displaying and running the command or not.

Example:


class Command1: IGeneralCommand
{

    public bool Show(SqlConnection Con, int personId)
    {
       bool show = false;
       bool isRequester = false;
       bool isOperator = false;

       // checking whether the user is in the Requesters group
       using (SqlCommand Cmd = new SqlCommand(@"SELECT CAST(1 AS bit) FROM tRolePerson WHERE liRolePersonRoleId = 7 AND liRolePersonPersonId = @personId", Con))
       {
          Cmd.Parameters.Add("@personId", SqlDbType.Int).Value = personId;
          isRequester = Cmd.ExecuteScalar() as bool? ?? false;
       }

       // checking whether the user is in the Operators group
       using (SqlCommand Cmd = new SqlCommand(@"SELECT CAST(1 AS bit) FROM tRolePerson WHERE liRolePersonRoleId = 9 AND liRolePersonPersonId = @personId", Con))
       {
         Cmd.Parameters.Add("@personId", SqlDbType.Int).Value = personId;
         isOperator = Cmd.ExecuteScalar() as bool? ?? false;
       }

       // if the user is a requester and not an operator, the command will be displayed
       if (isRequester && !isOperator)
          show = true;

       return show;
    }

}

Defining actions performed by the command

In the command class created, implement the Run method from the IGeneralCommand interface. The input parameter personId contains the id of the person who runs the command.

The output is a truth value based on the success of execution, a text which can be displayed in the message for the user, and a URL to open in a browser.

Example:


class Command1: IGeneralCommand
{

    public TupleRun(SqlConnection Con, int personId)
    {
       bool complete = false;
       string message = "";
       string url = "";

       // Checking whether the conditions for running/displaying the command changed in the period between displaying and running it or not (can be executed anywhere in this Run method).
       if (!Show(Con, personId))
       {
          message = "The command cannot be executed as the conditions for its displaying have not been met.";
          complete = false;
          return Tuple.Create(complete, message, url);
       }

       // Finding out the WA address
       HelpdeskWebService sdws = new HelpdeskWebService();
       string waUrl = sdws.GetServiceDeskPortalUrl();

       if (!string.IsNullOrEmpty(waUrl))
       {
          // Part of the service catalog for problem reporting
          string problems = "/NewTicket/SectionCatalog/45";
          url = waUrl + problems;

          complete = true;
       }
       else
       {
          message = "The command cannot be executed as URL settings for WebApp are missing in the ALVAO system. Please contact the ALVAO system administrator.";
          complete = false;
       }
       return Tuple.Create(complete, message, url);
    }

}

Tip:
If the custom command should open another page from ALVAO WebApp, use the GetServiceDeskPortalUrl() method from the Service Desk Web Service interface to find the root URL of WebApp. E.g.:
string waUrl = "";
using(HelpdeskWebService ws = new HelpdeskWebService())
{
    waUrl = ws.GetServiceDeskPortalUrl();
}
if (waUrl.Length == 0)
    throw new Exception("WebApp address not set.");

 

Did not find what you were looking for? Ask our technical support team.