- 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:58 AM - edited 09-15-2023 05:00 AM
Hi @Lavanya Nagendr , use a RegEx and replace function for that.
var str = g_form.getValue('description');
var result = str.replace(/([^a-z|^A-Z|^\s]*)/gm,"").trim();
g_form.setValue('u_description_1', result);
Greets
Daniel
Please mark reply as Helpful/Correct, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 04:08 AM
var str = g_form.getValue('description');
var result = str.replace(/([^a-zA-Z\s]*)/gm,"").trim();
g_form.setValue('u_description_1', result);
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1393773