- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 03:36 AM
Hi All,
I have a requirement where i need to get the "Descripion" field and auto populate another field lets say."Description 1" but without any numbers.
For example:
if Description ----is--> General Requirement 1.1
then Description 1 ---should be---> General Requirement
Note: The content on the Description may vary and the numbers like(1.1 or 1.04) will always be at the end.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 04:23 AM
You can put like below
var description = "General Requirement 1.1 @%";Regex explaination :
description = description.replace(/[0-9.]/g, '');
var description_1= description;
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 03:53 AM
You can use replace function
var description = "Servicenow 123 hello world 232 g 4";
description = description.replace(/[0-9]/g, ''); //replace with empty string
var description_1 = description;
gs.info(description_1);
Output :
for replacing any other characters you need to update regex.
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 04:15 AM - edited 09-15-2023 04:16 AM
Hi @Vishal Birajdar ,
Its working but the result i got for
var description = "General Requirement 1.1";
description = description.replace(/[0-9]/g, '');
description 1= description;
General Requirement 1.1
Output:
General Requirement .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 04:23 AM
You can put like below
var description = "General Requirement 1.1 @%";Regex explaination :
description = description.replace(/[0-9.]/g, '');
var description_1= description;
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 04:39 AM