Next Topic

Previous Topic

Book Contents

IF-ELSE-STEP Service Desk Commands

The following is a summary of IF-ELSE and STEP statements used in Service Desk procedures.

IF-ELSE Statements

Check a Variable

Evaluate a given variable.

Is Within Coverage

Tests whether a ticket or KB article is currently within the coverage schedule.

Tests for Duplicate Requests

Compares inbound email to determine if it is a duplicate of an existing ticket.

Test a Custom Field of the Ticket

Compares a custom field value in a ticket to a specified value or variable.

Test a Property Value of the New Ticket

Compares the value of a field in a ticket to a specified value or variable.

Test a Property Value of the Receipt

Compares the value of a field in an inbound email to a specified value or variable.

STEP Statements

Add a Note

Adds a note to the ticket being processed by the procedure.

Assign Object Property

Assigns a value to the property of a new ticket created using the Create Ticket command.

Assign Ticket Custom Field

Assigns a value to a custom field in a ticket.

Assign Ticket Property

Assigns a value to the property of the current ticket.

Create Ticket

Creates a new ticket in a specified service desk.

Delete a Ticket

Deletes the ticket being processed by the procedure.

Execute a Common Sub-Procedure

Starts another procedure.

Execute an External Script

Executes a script written in C#.

executeShellCommand()

Executes a shell command on the Kaseya Server

Execute SQL Non-Query

Executes an SQL non-query command on the Kaseya Server SQL Server database.

Execute SQL Select Query

Executes an SQL select query command on the Kaseya Server SQL Server database.

Fails the Current Ticket Transaction

Changes made to a ticket are not saved to the database.

Get Agent Property

Returns a selected property value from the last audit of the agent machine associated with the ticket.

Get a Variable

Gets a entered value or a value from a file stored on the Kaseya Server.

Link to Another Ticket

Associate another ticket with the ticket being processed.

Pause Stage Goal

Pause counting elapsed time against the stage goal.

Pause Ticket Goal

Pause counting elapsed time against the ticket goal.

Resume Stage Goal

Resume counting elapsed time against the stage goal.

Resume Ticket Goal

Resume counting elapsed time against the ticket goal.

scheduleProcedure()

Runs a selected agent procedure for a specified machine.

sendEmail()

Sends an email to one or more recipients.

sendMessage()

Sends a message to the inbox of a user.

Send a Text Message

Sends a text message to a mobile device. Not yet implemented.

Send a Voice Message

Converts a text message to a voice message and sends it to a mobile device. Not yet implemented.

Send Message to Pool Users

Sends a message to the inbox of each user included in a pool.

Set Escalation Time

Sets the time a ticket is escalated.

Set Goal Time

Sets the time a ticket or stage goal is scheduled to be completed.

Set Ticket Goal Time

Set the due date for the entire ticket.

writeProcedureLogEntry()

Writes an entry to System > Application Logging.

Where Used

These IF-ELSE and STEP statements are used by the following types of Service Desk procedures.

IF-ELSE Statements

Stage Entry or Exit

Ticket Change

Ticket Request De-Dup

Ticket Request Mapping

Ticket Goals

Ticket Escalations

Sub-Procedures

Check a Variable

Is Within Coverage

 

 

Tests for Duplicate Requests

 

 

 

 

 

 

Test a Custom Field of the Ticket

 

Test a Property Value of the New Ticket

 

Test a Property Value of the Receipt

 

 

 

 

 

 

STEP Statements

Stage Entry or Exit

Ticket Change

Ticket Request De-Dup

Ticket Request Mapping

Ticket Goals

Ticket Escalations

Sub-Procedures

Add a Note

 

Assign Object Property

 

 

Assign Ticket Custom Field

 

Assign Ticket Property

Create Ticket

 

 

Delete a Ticket

 

Execute a Common Sub-Procedure

executeShellCommand()

Execute SQL Non-Query

Execute SQL Select Query

Fails the Current Ticket Transaction

 

 

Get Agent Property

 

 

Get a Variable

Link to Another Ticket

 

Pause Stage Goal

 

 

Pause Ticket Goal

 

 

Resume Stage Goal

 

 

 

Resume Ticket Goal

 

 

scheduleProcedure()

sendEmail()

sendMessage()

Send Message to Pool Users

 

Set Escalation Time

 

Set Goal Time

 

Set Ticket Goal Time

 

 

writeProcedureLogEntry()

IF-ELSE in Detail

Check a Variable

Enter the name of the variable in the format #var_name#. It can be a global variable or a procedure variable that was defined earlier in the current procedure or a parent procedure. If a global variable, then the global variable's Set value must be compatible with the procedure being run. See Procedure Variables and Working with Variables for more information about variables.

Enter a string comparison operator. The same string comparison options are available for all IF commands. See String Comparisons and Date/Time Comparisons.

Then enter a second value to compare against the first value. Instead of a value you can also enter a property variable in the format [$objectname$] or a global variable or procedure variable in the format [=var_name=]. See Standard and Custom Property Variables for a list of property variables.

If the test is true, IF steps are executed. If the test is false, ELSE steps are executed.

Is Within Coverage

This IF command is not available for Ticket Request De-Dup and Ticket Request Mapping procedures.

Tests whether a ticket or KB article is currently within the coverage schedule.

Tests for Duplicate Requests

This IF command is only available in a Ticket Request De-Dup procedure.

Tests a ticket request to see if it is a duplicate of any existing ticket. Prevents multiple tickets from being created for the ticket request, within a specified time limit.

Ticket requests are created from either inbound emails or system events, such as alarm conditions. Incoming Email and Alarm Settings and linked service desk procedures determine how ticket requests are processed into tickets, what service desks are used to create the tickets, and whether ticket requests are canceled.

Tests true if one or more of the following conditions are matched:

  • Match the submitter name
  • Match the submitter email address
  • Match the request subject
  • Match the source type
    • 0 – Counter
    • 1 – Service
    • 2 – Process
    • 3 – SNMP
    • 4 – Alert
    • 5 – System Check
    • 6 – KES
    • 7 – Log Parser
  • Match the first reference field - Refers to the event ID and value ID of an event log alert.
  • Match the second reference field - Refers to the alert log type, which is either a system check or an event log alert. Event log alerts are classified as "6 = custom" log type alerts.
    • 1 = web server check
    • 2 = dns check
    • 4 = port check
    • 5 = ping
    • 6 = custom
  • Match the machine
  • Match the machine group
  • Enter Recurrence Time (Integer) / The Unit of Time - Limits matching to the most recent <N> number of periods, based on the ticket creation date.

Test a Custom Field of the Ticket

Enter the name of the custom field in the format custom_field, without bracket characters of any kind.

Enter a string comparison operator. The same string comparison options are available for all IF commands. See String Comparisons and Date/Time Comparisons.

Then enter a second value to compare against the first value. Instead of a value you can also enter a property variable in the format [$objectname$] or a global variable or procedure variable in the format [=var_name=]. See Standard and Custom Property Variables for a list of property variables. See Procedure Variables and Working with Variables for more information about variables.

If the test is true, IF steps are executed. If the test is false, ELSE steps are executed.

Test a Property Value of the New Ticket

Select a ticket property from the drop-down list.

Enter a string comparison operator. The same string comparison options are available for all IF commands. See String Comparisons and Date/Time Comparisons.

Then enter a second value to compare against the first value. Instead of a value you can also enter a property variable in the format [$objectname$] or a global variable or procedure variable in the format [=var_name=]. See Service Desk Property Variables for a list of property variables. See Procedure Variables and Working with Variables for more information about variables.

If the check is true, IF steps are executed. If the check is false, ELSE steps are executed.

Test Property Value of the Receipt

This IF command is only available in a Ticket Request Mapping procedure.

Select a ticket property from the drop-down list, in the format objectname, without bracket characters of any kind.

Enter a string comparison operator. The same string comparison options are available for all IF commands. See String Comparisons and Date/Time Comparisons.

Then enter a second value to compare against the first value. Instead of a value you can also enter a property variable in the format [$objectname$] or a global variable or procedure variable in the format [=var_name=]. See Standard and Custom Property Variables for a list of property variables. See Procedure Variables and Working with Variables for more information about variables.

If the test is true, IF steps are executed. If the test is false, ELSE steps are executed.

SourceType, SourceTag and SourceValue Properties

The SourceType, SourceTag and SourceValue properties are populated when ticket creation is triggered by a system event and Service Desk integration is activated. For example, various types of alarms conditions can trigger the creation of a ticket. The following table shows how the SourceType and three SourceTag fields are populated by a variety of alarm conditions. The SourceValue columns—not shown in this table—contain the specific values that correspond to these SourceTag fields.

SourceType

SourceTag1

SourceTag2

SourceTag3

Event Log

agentguid

alertid

EventLogTypeId

Counter

agentguid

monitorobjectid

 

Agent Offline

agentguid

alertid

 

Service

agentguid

monitorobjectid

 

New Patch

agentguid

alertid

 

Agent Credential Invalid

agentguid

alertid

 

Win AU Change

agentguid

alertid

 

RAM Change

agentguid

alertid

 

Disk Drive Change

agentguid

alertid

 

Agent Online

agentguid

alertid

 

PCI Card Change

agentguid

alertid

 

System Check

agentguid

alertid

 

All Alerts

The following fields are set for all tickets generated from all alerts:

  • sourceType = alert name (name of actual alert for sourceValue2)
  • sourceTag1 = "AgentGuid" (string label - never changes)
  • sourceValue1 = the actual agentGuid triggering the alert
  • sourceTag2 = "AlertRegistrationId" (string label - never changes)
  • sourceValue2 = the alert ID (primary key in alertRegistration table; identifies the actual alert)

Event Log Alert

Note: Only the Event Log, Missing Event Log, and Multiple Event Log alerts (SourceType) have more than two SourceTag fields.

The following fields are set for all tickets generated for the specified event log alert. 3, 4 and 5 sourceTags and sourceValues are generated for Missing Event Log Alerts and Multiple Event Log Alerts.

  • sourceTag3 = "LogType" (string label - never changes)
  • sourceValue3 = logType value (value in eventLogType.EventLogTypeId; ** see below)
  • sourceTag4 = "LogTypeLabel" (string label - never changes)
  • sourceValue4 = logType label (value in eventLogType.logfileName for LogType value; ** see below)
  • sourceTag5 = "EventSetName" (string label - never changes)
  • sourceValue5 = eventSet name
  • sourceTag6 = "EventId" (string label - never changes)
  • sourceValue6 = eventId
  • sourceTag7 = "EventSource" (string label - never changes)
  • sourceValue7 = eventSource
  • sourceTag8 = "EventMessage" (string label - never changes)
  • sourceValue8 = eventMessage

LogType Values from the eventLogType Table

EventLogTypeId

logFileName

286518283

Directory Service

635771359

Internet Explorer

796450521

Application

1208407329

DNS Server

1380569194

System

1664713117

Security

String Comparisons

The string comparisons performed in IF commands are not case sensitive. The available tests are:

  • Exists : true if the variable exists and the variable has a non-empty value
  • Does Not Exist : true if the variable does not exist or the variable has an empty value
  • Is Equal To : true if value of the variable equals the test value.
  • Is Not Equal To : true if value of the variable does not equal the test value.
  • Is Greater Than : true if value of the variable is greater than the test value.
  • Is Greater Than or Equal To : true if value of the variable is greater than or equal to the test value.
  • Is Less Than : true if value of the variable is less than the test value.
  • Is Less Than or Equal To : true if value of the variable is less than or equal to the test value.
  • Contains : true if the test value is a sub string of the variable (variable must be a string).
  • Does Not Contain : true if the test value is not a sub string of the variable (variable must be a string).

For the tests Is Equal To, Is Not Equal To, Is Greater Than, Is Greater Than or Equal To, Is Less Than, and Is Less Than or Equal To the variables compared may be a string, a number, a date in the format of yyyy/mm/dd or yyyy/mm/dd hh:mm or yyyy/mm/dd hh:mm:ss, or a version number containing dots or commas such as 1.2.3 or 4,5,6,7. If a date format is specified, it may be offset using + dd:hh:mm:ss or - dd:hh:mm:ss. Only dd days are required; hh hours, mm minutes, and ss seconds may be omitted and are assumed to be zero when absent.

Date/Time Comparisons

You can use an IF statement to test whether a time relative to the current time is true or not. Relative time is specified as [-][d.]hh:mm:ss where d is the number of days, hh is the number of hours, mm is the number of minutes, and ss is the number of seconds . Specifying a in front causes a time in the past to be calculated. Thus -1:00:00 means one hour ago, -3.12:45:08 means three days, 12 hours, 45 minutes, and 8 seconds ago. Notice that days has a period just after it instead of a colon. Specifying d and - are optional. These times do not take into account hours coverage associated with a policy. For example, an IF statement can test to see whether a ticket's create date/time is older than 3 days. The first value is CreateDateTime, the operator is Is Less Than, and the comparison value is -3.00:00:00.

STEP in Detail

Add a Note

Adds a note to the ticket being processed by the procedure. You choose to make the note hidden or not.

Select a note template instead of entering a note.

Note text can include an property variable in the format [$objectname$] or a global variable or procedure variable in the format [=var_name=]. See Standard and Custom Property Variables for a list of property variables. See Procedure Variables and Working with Variables for more information about variables.

Assign Object Property

Assigns a value to the property of a new ticket created in a previous service procedure step using the Create Ticket command.

  • The name of the global variable used to reference the New Ticket - Enter the name of the global variable without [= and =] brackets. If multiple Create Ticket steps are included in the same procedure, each should specify a different global variable so that each new ticket can be uniquely identified in subsequent steps.
  • The name of the property to assign - The name of the ticket property to assign.
  • The value for the property - The value to assign the ticket property.

The set of properties that can be assigned are displayed in a drop-down list. See Working with Variables for more information about variables.

Note: Use Assign Ticket Property to assign a value to the property of the current ticket.

Assign Ticket Custom Field

Assigns a value to a custom field in a ticket. Enter the name of the custom field in the format custom_field, without bracket characters of any kind. Then enter a value that matches the range of possible values allowed for this custom field. The range of possible values is specified using the Service Desk > Desk Definition > Properties > Custom Fields tab.

You can also enter a property variable in the format [$objectname$] or a global variable or procedure variable in the format [=var_name=]. See Standard and Custom Property Variables for a list of property variables. See Procedure Variables and Working with Variables for more information about variables.

Assign Ticket Property

Assigns a value to the property of the current ticket. The set of properties that can be assigned are displayed in a drop-down list. The supplied value may be a global variable name or procedure variable name in the format [=var_name=]. See Procedure Variables and Working with Variables for more information about variables.

Note: Use Assign Object Property to assign a value to the property of a new ticket created using the Create Ticket command.

Create Ticket

Creates a new ticket in a specified service desk.

  • The name of the service - The name of the service desk.
  • Summary for the new ticket - The summary of the ticket.
  • (Description) - The description of the ticket.
  • The global variable where the reference to the new ticket - The name of a global variable used to reference this newly created ticket in subsequent Assign Object Property steps. If multiple Create Ticket steps are included in the same procedure, each should specify a different global variable so that each new ticket can be uniquely identified in subsequent steps. Enter the name of the global variable without [= and =] brackets.

Events occur in the following order:

  1. Assign Object Property steps in subsequent steps assign values to the properties of the newly create ticket.
  2. After the new tickets are created, if there are properties of the ticket that have not been set using Assign Object Property steps, but have defaults in the service desk, those default values are applied to the ticket.
  3. If there is a stage entry procedure for the service desk associated with the new ticket's beginning stage, that is run last.

Delete a Ticket

Deletes the ticket being processed by the procedure.

Execute a Common Sub-Procedure

Causes a sub-procedure to execute. Use this capability to string multiple IF-ELSE clauses together. You can nest the execution of procedures to 10 levels.

Execute an External Script

Executes a script written in C#. This command only displays when KSD 1.3 is installed in VSA 6.2 or later. The VBScript and JScript options are not yet implemented. See the Execute an External Script community page for details.

executeShellCommand()

Executes a shell command on the Kaseya Server. Runs from the \windows\system32 directory. For example, the shell command dir c:\temp runs the directory command from \windows\systems32 directory but displays the directory for c:\temp. When running a batch file use a cd command at the top of the batch file to change directories and run all subsequent commands from that directory. Separate fields are provided to direct the output of the command line to an output file or to a variable. If the output file exists, it is overwritten.

Execute SQL Non-Query

Executes an SQL non-query command on the Kaseya Server SQL Server database. This option only displays for master role users.

Warning: Direct manipulation of the Kaseya Server database can result in a massive loss of data. For example executing the Execute SQL Non-Query command DELETE FROM kasadmin.SDIncident will delete all tickets.

  • Enter the command to execute - Specify an SQL non-query without brackets or quotes.
  • Perform Step On - Specify the type of operating system to perform this step on.

Execute SQL Select Query

Executes an SQL select query command on the Kaseya Server SQL Server database. This option only displays for master role users. For example, the Execute SQL Select Query command SELECT * FROM kasadmin.SDIncident WHERE REF=’[$TicketID$]’ returns all of details for the current ticket.

  • Enter the command to execute - Specify an SQL select query without brackets or quotes.
  • The variable where the results are stored - Specify the variable name without brackets. Example: var_name.
  • Perform Step On - Specify the type of operating system to perform this step on.

Fails the Current Ticket Transaction

If included in a procedure, cancels all changes to the ticket. Cancels both ticket changes made manually before saving the ticket and ticket changes made within the procedure being processed prior to this step being run. Does not cancel sendEmail() or sendMessage() steps processed before this step is run. Cancels all steps in the procedure after this step is run.

Get Agent Property

Returns a selected property value from the last audit of the agent machine associated with the ticket.

  • The vMachine property to retrieve from the agent - See Audit > Audit Summary for a description of each property.
  • The variable to hold the value of the agent property - Specify the variable name without brackets. Example: var_name.
  • Perform Step On - Specify the type of operating system to perform this step on.

Get a Variable

Defines a new procedure variable and assigns it a value. Specify the variable name without brackets. Example: var_name.

You can refer to this variable in text fields in any subsequent steps by adding [= and =] around the variable name. Example: [=var_name=]. See Procedure Variables and Working with Variables for more information about variables.

  • Constant Value - Enter a value for the variable.

Link to Another Ticket

Links the ticket being processed to a specified ticket ID or knowledge base article ID.

Pause Stage Goal

Pauses counting elapsed time against the current stage goal. Goal procedures are linked to stages using the Service Desk > Desk Definition > Processing > Stage > Procedures tab.

Pause Ticket Goal

Pauses counting elapsed time against the ticket goal. The ticket goal determines the due date for the entire ticket. Goals are linked to a service desk using the Desk Definition > Properties > General > Procedures tab.

Resume Stage Goal

Resumes counting elapsed time against the current stage goal. Goal procedures are linked to stages using the Service Desk > Desk Definition > Processing > Stage > Procedures tab.

Resume Ticket Goal

Resumes counting elapsed time against the ticket goal. The ticket goal determines the due date for the entire ticket. Goals are linked to a service desk using the Desk Definition > Properties > General > Procedures tab.

scheduleProcedure()

Runs a selected agent procedure for a specified machine. Use [$FullMachineName$] to specify the machine name and machine group, assuming a machine is associated with the ticket. Otherwise you can enter a procedure variable for the machine name or specify a fixed machine name value.

sendEmail()

Sends an email to one or more recipients. Specifies the subject and body text of the email.

Optionally check the Send the email if the body contains the [$ChangesAsHtml$] or [$Changes$] and those properties are empty due to hidden notes. This prevents emails with "empty" notes from being sent.

You can include property variables, global variables and procedure variables in the To, From, Subject, and Body fields of a sendEmail() command. You can reference property variables, global variables and procedure variables in the message templates you link to in a sendEmail() command. See Standard and Custom Property Variables for a list of property variables. See Procedure Variables and Working with Variables for more information about variables.

You can also enter the name of a pool of users. Names are delimited using commas or semi-colons. The following order of precedence determines the email addresses of recipients. The name in the To field of a sendEmail() step is checked to see if it:

  • Exists as a user name. If that name is found, and an email address exists for that user, then that email address is used.
  • Conforms to an SMTP email address. For example, user@domain.com. If the name matches that pattern, that name is used for the email address. If a service desk pool name conforms to an email address, then email will be sent to that email address, not to the pool of users in that pool.
  • The name is looked up as a service desk pool. The email is sent to the email addresses associated with each user in the pool.

sendMessage()

Sends a message to the Inbox of a user.

You can only enter one user name in the To field of the sendMessage() dialog box. Use sendMessage() to User Pool to send a message to multiple users.

You can include property variables, global variables and procedure variables in the To, From, Subject, and Body fields of a sendMessage() command. You can reference property variables, global variables and procedure variables in the message templates you link to in a sendMessage() command. See Standard and Custom Property Variables for a list of property variables. See Procedure Variables and Working with Variables for more information about variables.

Sends a text message to a mobile device. Not yet implemented.

Converts a text message to a voice message and sends it to a mobile device. Not yet implemented.

Send Message to Pool Users

Sends a message to the Inbox of all users in a selected pool.

You can include property variables, global variables and procedure variables in the Subject, and Body fields of a Send Message to Pool Users command. You can reference property variables, global variables and procedure variables in the message templates you link to in a Send Message to User Pool command. See Standard and Custom Property Variables for a list of property variables. See Procedure Variables and Working with Variables for more information about variables.

Set Escalation Time

Sets the time a ticket is escalated. Overrides the default escalation time set for a stage using the Service Desk > Desk Definition > Processing > Stage > Procedures tab. The escalation time can be calculated using the coverage schedule associated with the ticket or using calendar time. For example, if a coverage schedule does not include weekend coverage, and the ticket escalation procedure runs during the weekend, escalation of the ticket will not start counting until coverage begins on Monday morning. If escalation time is calculated using:

  • Calendar time, and a coverage schedule is associated with the ticket, calendar time is used.
  • A coverage schedule, and no coverage schedule is associated with the ticket, calendar time is used.

Set Goal Time

Sets the time the goal for a stage is scheduled to be completed. Overrides the default goal time set for a stage using the Service Desk > Desk Definition > Processing > Stage > Procedures tab.

Set Ticket Goal Time

Sets the time the goal for a ticket is scheduled to be completed. The ticket goal determines the due date for the entire ticket. Overrides the default goal time set for a ticket using the Desk Definition > New or Edit > Procedures tab.

writeProcedureLogEntry()

Writes the supplied string to System > Application Logging.