How to remove spaces in a catalog item variable ?

Jo Chatterjee
Giga Expert

Hello I have requirement, wherein if a user types in the variable (select box) - "this is a test name" then it should display as "thisisatestname" in the RITM and task. I have written the below simple code but doesn't work.

OnSubmit Client script

function onSubmit() {
//Remove spaces from the field
var first = g_form.getValue('variable1');
g_form.setValue('variable1',first.trim());
}

1 ACCEPTED SOLUTION

Murthy Ch
Giga Sage

Hi @Jo Chatterjee 

Instead of trim use replace method.

Thanks & BR,

Murthy

Thanks,
Murthy

View solution in original post

6 REPLIES 6

Jo Chatterjee
Giga Expert

Hi All,

.replace worked fine. Thank you so much.

 

I had not checked the Apply to catalog item and apply to task check boxes, that is the reason why it was not populating. 🙂 Thank you again.

Glad you got this working.  Community etiquette note: Since only one answer can be marked as  'correct', it is customary to mark the response containing the correct answer that was posted first.  Sometimes people opt to award the one that supplied the actual code and/or a link to a documented solution over one that just suggests an idea, but in the end it is entirely up to you.