How to remove double spaces for a field in the form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-18-2023 05:58 AM
Hi Team,
I have 2 string field in my form. Fund Name and Fund Number. How can I clean up the the existing this 2 field with leading double spaces?
Please suggest the way and a example code
Regards,
Sruthi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-19-2023 01:34 AM
Hi,
I tried the below fix script but it is not removing the extra spaces after Run Fix Script. Please sugges
I have added spaces before Testing as below. But not removing the extra spaces after Run Fix Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-19-2023 01:55 AM
Hi @sruthig
Try below Script once:
var gr = new GlideRecord('sn_customerservice_case');
gr.query();
while (gr.next()){
gs.addInfoMessage(gr,number); // Info Msg just to verify that code is going inside the While loop correctly or not
var clean1 = gr.<field_name>.toString().trim();
gr.<field_name> = clean1;
gr.setWorkflow(false);
gr.update();
}
Verify that you are getting Info Message.
You can also try with some filter on addQuery() and setLimit() to validate few records first than go for the whole table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-22-2023 09:49 AM
Hi Anubhav,
Thanks for the response. It's working when I add string().
Can you please help me how to remove extra space in between 2 strings(Words)
Example - Testing Test (If in between Testing and Test, 2 spaces then how to remove the one space)
Please suggest.
Regards,
Sruthi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-23-2023 06:28 AM
You can use the replace() method.
var string = 'Testing Test';
var newString = string.replace(' ', ' '); //replace the double space ' ' with a single space ' '
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-29-2023 04:52 AM
Hi,
You are just using 'Testing Test'. There are many record with these double space. How can I add condition to remove double space or more spaces in fix script. Not for single record.
Please suggest.