In servicenow, if we create any incident from the catalog item then a message is showing that incxxxxxx created.. I am trying to figure out how to change the message that appears whenever a new record is inserted into the Incidents table using the ServiceNow Portal. Can someone please assist with this?
Assistant
To customize the message that appears whenever a new incident record is inserted via the ServiceNow Portal, you will need to modify the client scripts or script includes related to the catalog item submission process. Here is a detailed approach to achieve this:
Step-by-Step Guide
Identify the Catalog Item:
Navigate to Service Catalog > Catalog Definitions > Maintain Items in the application navigator.
Identify and open the catalog item for which you wish to change the notification message.
Locate the Submit Script:
Catalog items have catalog client scripts or UI policies associated with them. These scripts manage what happens when the item is submitted.
Navigate to the Related Links section of the catalog item form and look at the existing catalog client scripts associated with the item.
Create/Edit a Catalog Client Script:
If there's already a catalog client script that handles the submission confirmation, you can edit it. Otherwise, you'll need to create a new one.
Navigate to Service Catalog > Catalog Definitions > Maintain Client Scripts.
Click New to create a new script or open the existing one.
Modification of the Client Script:
Inside the client script, you'll need to modify the script that defines the message shown upon successful submission.
Below is a sample code snippet for a client script that changes the confirmation message:
javascript
function onSubmit() {
// Disables the default submission behavior to allow for custom message handling
return false;
}
function onComplete() {
// Customize this variable to your desired confirmation message
var customMessage = "Your incident has been successfully created. The reference number is: " + g_form.getDisplayValue('number');
// Show a confirmation message to the user
alert(customMessage);
// Optionally, execute any other logic needed
// You could also use g_navigation.open() to redirect or show a custom page
}
Configure the Script Include for Server-Side Logic:
In some scenarios, the notification is driven by server-side scripts. Check for any script includes or business rules tied to the creation of incidents via catalog items.
Verify Incident Creation Script:
If your ROI (Return on Investment) process involves a server-side script include, you should find and modify it accordingly.
Navigate to System Definition > Script Includes and find the script handling incident creation.
Modify the script to include your custom message logic if necessary.
Testing the Changes:
Once your modifications are complete, test the catalog item submission through the Service Portal.
Ensure the new message displays correctly and no other functionalities are broken.
Example Scenario
Client Script Named:CS_INC_ConfirmationMessage
javascript
(function executeRule(current, previous /*null when async*/) {
// Assuming a script triggered on incident creation via catalog item
// Retrieve necessary details
var incidentNumber = current.number;
// Your custom message logic
gs.addInfoMessage("Your incident has been successfully created. Reference number: " + incidentNumber);
// Optional redirect after showing the message (if it aligns with your UX needs)
// gs.getSession().putClientData('redirect_uri', '<YOUR_REDIRECT_URL>');
})(current, previous);
It's essential to test the customization in a development or test environment before applying changes to the production environment to ensure it meets the necessary requirements without impacting any existing functionalities.
Helpful Tips:
Keep your messages clear and concise for better user experience.
Always back up existing scripts before making modifications.
Ensure necessary access controls are in place to safeguard against unauthorized modifications.
With this approach, you should be able to create or modify the script that displays a customized confirmation message when an incident is created via a catalog item in the ServiceNow Portal.