- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 11:55 PM
Hi folks,
Looking to remove ".0" off of String fields that have accumulated over the years.
Here's what I'm trying to execute. Alternatively, I tried using .slice as well. I can't shake the feeling it's something basic and I should probably stop working at 3am.
var trailingZero = new GlideRecord("task");
trailingZero.addEncodedQuery('fieldLIKE.0');
while(trailingZero.next()) {
var trailingGone = trailingZero.field.replace(/.0/,'');
trailingZero.setValue('field,trailingGone);
trailingZero.update();
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2024 12:05 AM - edited 06-11-2024 12:05 AM
Hi @Vivin Viswanath ,
I fixed your script in my PDI there are some error in that. Please refer below code
var trailingZero = new GlideRecord("task");
trailingZero.addEncodedQuery('fieldLIKE.0');
trailingZero.query();
while(trailingZero.next()) {
var field = trailingZero.getValue("field");
var trailingGone = field.replace(".0",'');
trailingZero.setValue('field',trailingGone);
trailingZero.update();
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2024 12:26 AM
Hi Vivin,
you can use the slice() method.
here is the code for your reference.
Thank you,
Vishal Khandve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2024 10:36 AM
Thanks, Vishal! I'll give this a try as well as Sartha's and see what we get.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 12:11 PM
Both yours and Sarthak's solutions worked. I marked them both as acceptable.