- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 09:19 PM
Hi All,
We have an input where we will get a value as short_description (For example lets say: 1 to 50 numbers in short_description)
I want the value which is after 1 to 30 characters.
How to trim the short_description value more than 30 characters
Regards,
Reddy
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 11:23 PM
So you need to write this in server-side script and run this accordingly.
For incident, you can do like this, which will update short description to 30 chars for all active incidents.
var gr = new GlideRecord("incident");
gr.addActiveQuery();
gr.query();
while(gr.next()) {
short_desc = gr.getValue("short_description");
gr.short_description = short_desc.substring(0,30);
gr.update();
}
mark the comment as a correct answer once worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 10:44 PM
already we have some data in short_description in incident more than 50 characters.
my scenario is trim existing data.
ex:-
before trim:- short_description=Service Now makes work, work better for people.
after trim:- short_description=Service Now makes work, work b (i need only 30 characters)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 10:55 PM
This line gives you only 30 characters
g_form.setValue('short_description', short_desc.substring(0,30)); // this will store the first 30 characters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 11:12 PM
Thanks Asifnoor.
i have tried Ur code it's working fine.
it's working record by record means ( single record only ). but i want to trim all records at a time.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 11:23 PM
So you need to write this in server-side script and run this accordingly.
For incident, you can do like this, which will update short description to 30 chars for all active incidents.
var gr = new GlideRecord("incident");
gr.addActiveQuery();
gr.query();
while(gr.next()) {
short_desc = gr.getValue("short_description");
gr.short_description = short_desc.substring(0,30);
gr.update();
}
mark the comment as a correct answer once worked.