ServiceNow Catalog - Short Description Manipulation

ArunG29061990
Tera Expert

Hi, 

 

I am modifying one catalog where I need to manipulate the short description. 

 

My current short description is like "Configuration Incident Response Team - P2P - AnyERP Task - High Memory/CPU - Tenant: KOK - SIDK - ServiceProvider"

 

but my requirement is "Configuration Incident Response Team - P2P - AnyERP Task - High Memory/CPU - Tenant: ServiceProvider"

 

So I want to remove this KOK - SIDK from every ticket. 

 

So basically this "KOK - SIDK" is a prefix for each and every tenant but we don't want it in short discription. So how to remove this?

 

Current code is :

current.short_description += producer.Issue_Category + " - " + "Tenant: " + producer.getDisplayValue("cmdb_ci");
 
and that tenant value is coming from " producer.getDisplayValue("cmdb_ci");" 
 
2 ACCEPTED SOLUTIONS

Eshwar Reddy
Kilo Sage

Hi @ArunG29061990 

To remove the prefix "KOK - SIDK" from the short description, add the following code immediately after the line:

// current.short_description += producer.Issue_Category + " - " + "Tenant: " + producer.getDisplayValue("cmdb_ci");

 

Insert this code

 

var prefixToRemove = "KOK - SIDK";
if (currentShortDescription.includes(prefixToRemove))
{
currentShortDescription = currentShortDescription.replace(prefixToRemove, '').trim(); // Remove the prefix and trim whitespace
}

Please mark this response as Correct and Helpful if it helps you can mark more that one reply as accepted solution

View solution in original post

okay @Eshwar Reddy 

 

I just made a few changes:

 

var prefixToRemove = "KOK - SIDK";
if (current.short_description.includes(prefixToRemove))
{ current.short_description = current.short_description.replace(prefixToRemove,'').trim(); }
 
It works 🙂
 
Thanks @Eshwar Reddy 

View solution in original post

10 REPLIES 10

@ArunG29061990 

Below script in working fine for me

 

EshwarReddy_0-1726739678043.png

 

Result

 

EshwarReddy_1-1726739709470.png