Next Topic

Previous Topic

Book Contents

comment()

Adds a one line comment to the procedure.

createTicket()

Creates a new ticket in a specified service desk.

Events occur in the following order:

  1. assignObjectProperty() 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 assignObjectProperty() 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.

deleteTicket()

Deletes the ticket being processed by the procedure.

executeSubProcedure()

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.

executeExternalScript()

Note: A No Approved External Scripts message displays in the Choose the external script to execute drop-down list if no external scripts have been manually added to the Kaseya Server, as described below.

Executes a script written in VB.Net (.vb) or CSharp (.cs) on the Kaseya Server from the following file locations.

executeExternalScript() XML files can have any filename. You can have multiple scripts in one file. You can also have multiple files. The scripts referenced by an XML file should be stored in the same location as the XML file under a \Script folder.

Example of VB.Net Script

This script writes to a file if the file exists.

Dim FILE_NAME As String = "c:\temp\test.txt"
If System.IO.File.Exists(FILE_NAME) = True Then
     Dim objWriter As New System.IO.StreamWriter( FILE_NAME )
     objWriter.Write( "Hello" )
     objWriter.Close()
End If

Place the script file in this location:

<Kaseya_Installation_Directory>\xml\SDProcExecuteScript\0\script\CreateFile.vb

Note: This example requires the creation of c:\temp\test.txt prior to execution. Also, the group IIS_IUSRS must have permissions to C:\temp.

Example of XML File

The XML should be structured like the following example, which includes 2 external scripts.

<?xml version="1.0" encoding="utf-8" ?>
<externalScriptList>
	<externalScriptDef label="First Script" fileName="createFile.vb">
	</externalScriptDef>
	<externalScriptDef label="Second Script" fileName="createFile2.vb">
	</externalScriptDef>
</externalScriptList>

Place the script file in this location:

<Kaseya_Installation_Directory>\xml\SDProcExecuteScript\0\VB.xml

Example of C#.Net Script


This script writes to a file if the file exists.

string FILE_NAME = "c:\\temp\\test.txt";
if (System.IO.File.Exists(FILE_NAME) == true) {
 System.IO.StreamWriter objWriter = new System.IO.StreamWriter(FILE_NAME);
 objWriter.Write("Hello");
 objWriter.Close();
}

Place the script file in this location:

<Kaseya_Installation_Directory>\xml\SDProcExecuteScript\0\script\CreateFile.cs

Note:: This example requires the creation of c:\temp\test.txt prior to execution. Also, the group IIS_IUSRS must have permissions to C:\temp.

Example of XML File


The XML should be structured like the following example, which includes 1 external script.

<?xml version="1.0" encoding="utf-8" ?>
<externalScriptList>
    <externalScriptDef label="Write to a file" fileName="CreateFile.cs">
    </externalScriptDef>
</externalScriptList>

Place the script file in this location:

<Kaseya_Installation_Directory>\xml\SDProcExecuteScript\0\CS.xml

Definitions

exitProcedure()

Exits the current procedure. There are no parameters to set.

executeShellCommand()

Note: A No Approved Shell Command message displays in the Choose the command to execute in a command shell drop-down list if no SQL commands have been manually added to the Kaseya Server, as described below.

Executes a shell command on the Kaseya Server from the following file locations.

Shell commands stored in these locations are formatted as XML files and can have any filename. You can have multiple commands in one XML file. You can also have multiple XML files.

Example

The XML should be structured like the following example, which includes 2 shell commands.

<?xml version="1.0" encoding="utf-8" ?>

<shellCommandList>

<shellCommandDef label="Shell Command 1" commandToExecute="echo hello" waitForCompletion="true" sendOutputToLog="true" outputFile="c:\temp\fromcmd.log" outputVariable="" />

<shellCommandDef label="Shell Command 2" commandToExecute="echo hello" waitForCompletion="true" sendOutputToLog="true" outputFile="c:\temp\fromcmd2.log" outputVariable="" />

</shellCommandList>

Definitions

At least one of the following is required. If both are filled in outputFile has precedence.

executeSqlNonQuery()

Note: A No Approved SQL message displays in the SQL Command to Execute drop-down list if no SQL commands have been manually added to the Kaseya Server, as described below.

Updates the database—such as updating the value in a column or inserting a row—by running a selected SQL "nonquery" statement. Global "nonquery" statements are specified in the following location: <C:\Kaseya\xml\SDProcSQL\0\SQLNonQuery\<filename.xml>.

Warning: Direct manipulation of the Kaseya Server database can result in a massive loss of data.

Filenames can be any name with an .xml extension so long as they are formatted correctly internally. Multiple statements specified using one or more XML files display as a single combined combo box list in the user interface. Each SQL statement in the XML file has a unique label, and only the labels are shown in the combo box. If no SQL statements are defined, then *No Approved SQL* displays in the combo box.

Partition-Specific Statements

Partition-specific folders can contain partition-specific SQL statements. For example: <C:\Kaseya\xml\SDProcSQL\123456789\SQLNonQuery\<filename.xml>. Users can select and run all 0 folder SQL "nonquery" statements and all SQL "nonquery" statements located in the partition path that matches the partition they are using.

Example Format

<?xml version="1.0" encoding="utf-8" ?>
<queryList>
    <queryDef label="Update Table" sql="UPDATE table1 SET column2 = value2 WHERE column1 = value1" />
</queryList>

executeSqlQuery()

Note: A No Approved SQL message displays in the SQL Command to Execute drop-down list if no SQL commands have been manually added to the Kaseya Server, as described below.

Returns a value from the database and stores it to a named variable by running a selected SQL "query" statement. Global "query" statements are specified in the following location: <C:\Kaseya\xml\SDProcSQL\0\SQLQuery\<filename.xml>

Filenames can be any name with an .xml extension so long as they are formatted correctly internally. Multiple statements specified using one or more XML files display as a single combined combo box list in the user interface. Each SQL statement in the XML file has a unique label, and only the labels are shown in the combo box. If no SQL statements are defined, then *No Approved SQL* displays in the combo box.

Partition-Specific Statements

Partition-specific folders can contain partition-specific SQL statements. For example: <C:\Kaseya\xml\SDProcSQL\123456789\SQLQuery\<filename.xml>. Users can select and run all 0 folder SQL "query" statements and all SQL "query" statements located in the partition path that matches the partition they are using.

Example Format

<?xml version="1.0" encoding="utf-8" ?>
<queryList>
    <queryDef label="Agent Guid" sql="SELECT machName FROM dbo.machNameTab WHERE agentGuid = 12345678910111213141516171" />
</queryList>

failCurrentTicketTransaction()

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.

getAgentInfo()

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

getVariable()

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.

linkTickets()

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

pauseStageGoal()

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.

pauseTicketGoal()

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.

reOpenTicket()

Changes an End-stage (for example, Closed) ticket to a Begin-stage (for example, New) ticket. Applies only to a Ticket Request Mapping procedure.

resumeStageGoal()

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.

resumeTicketGoal()

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 Ticket Properties and 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:

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 Ticket Properties and Variables for a list of property variables. See Procedure Variables and Working with Variables for more information about variables.

sendMessageToPool()

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 sendMessageToPool() 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 Ticket Properties and Variables for a list of property variables. See Procedure Variables and Working with Variables for more information about variables.

setEscalationTime()

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:

setGoalTime()

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.

setTicketGoalTime()

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.