I’ve been working with a few clients recently extending the capabilities of their ServiceDesk Plus Service Catalogue templates. On a number of occasions the issue of time wasted owing to incorrect data being logged has arisen. A couple of these issues related to the logging of data such as making sure numeric data is consistent and date validation. Often these issues arise as a result of collecting data, in a new starter process for example. For one client the logging of an Employee ID number was of particular importance. In collecting this data it was important to verify that the length of the ID number was correct. As an added complication they also used different length ID numbers for different sites in the business. In truth this issue was easily handled using the scripting capabilities offered by the Field and Form Rule capabilities of ServiceDesk Plus. The field and Form Rules already give an example of how to perform numeric validation:
All the customer needed to do in this instance was to check if the number entered was 4 or 6 digits long depending on the Site of the requester. To achieve this we simply modified the script to check the numeric range, and therefore length, of the data entered into this field. The “ServiceReq_601_UDF_LONG1” variable represented the name of the custom field that had been created to record the Employee ID number (the script tool shows this field name based on the field label name so it’s easy to locate and identify):
var numericFieldVal = $CS.getValue("ServiceReq_601_UDF_LONG1");
/*checks if numeric fields is non-empty*/
if (numericFieldVal!=='')
{
/*checks if numeric field's value is numeric constant*/
if (jQuery.isNumeric(numericFieldVal))
{
/*parse string to numeric value*/
var numericValue = parseInt(numericFieldVal);
/* i.e. test if less than 4 characters */
if (numericValue < 1000)
{
alert("Value of xyz cannot be less than four digits");
/*stop form submission*/
$CS.stopFormSubmission();
}
/* i.e. test if greater than 4 characters */
if (numericValue > 9999)
{
alert("Value of xyz cannot be more than four digits");
/*stop form submission*/
$CS.stopFormSubmission();
}
}
else
{
alert("Enter a valid numeric constant");
/*stop form submission*/
$CS.stopFormSubmission();
}
}
All we then need to do was apply this script to a Field and Form Rule when submitting the ServiceDesk Plus form or to have the check performed when the form was being edited when the user was entering data into the Employee ID field. By having separate Rules that used the condition check of the Site field we could use the script, with appropriate modifications, to test for entries of 4 digit and 6 digit Employee ID numbers. For the purists I could have simply checked the length of the numerical input using the Javascript ‘length’ element and using this in the ‘if’ statement tests:
numericLen=numericFieldValue.length;
However, as a first pass and without the need to Google, this did the job ;0) I’ll provide an example of Date based verification example in Part 2. Enjoy!
This article is relevant to:
Service DeskOther recent articles in the same category
You may be interested in these other recent articles
Third Party Integration with ServiceDesk Plus: A Standardised Approach
5 February 2025
In today’s fast-paced IT landscape, businesses rely on third-party application integrations to streamline workflows and enhance operational efficiency. To unlock the full potential of these…
Read moreExport Contracts in ServiceDesk Plus: A Practical Solution
30 January 2025
Find out how customers who need to export contracts from ServiceDesk Plus come to Set3 Solutions for expert guidance.
Read moreLatest Updates for ManageEngine Endpoint Central
27 January 2025
Discover the latest Endpoint Central updates, including new features, fixes, and enhancements.
Read moreStay Ahead with the Latest Updates for ManageEngine OpManager
22 January 2025
Discover the latest OpManager updates, including new features, fixes, and enhancements.
Read moreLatest Updates for ManageEngine ServiceDesk Plus Cloud
18 January 2025
Discover the latest ServiceDesk Plus Cloud updates, including new features, fixes, and enhancements.
Read more