MRVS Onsubmit Trim spaces

Rajeevreddy
Tera Expert

Hi All ,

 

I have catalog item i am using varible set under it i have multi row variable set in that i have one field called test which is a single line text . before submitting form if i have any spaces before it should clear . how do i do .

 

  var str = g_form.getValue('variable_1');
        var wsr = str.trim();
        g_form.setValue('variable_1',wsr );
    

 

This is the one i used  

1 ACCEPTED SOLUTION

Try on some onChange script first

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

View solution in original post

9 REPLIES 9

Try on some onChange script first

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

Chaitanya ILCR
Kilo Patron

Hi @Rajeevreddy ,

Did you create the client script in the MVRS (variable set)?

if not create the client script in the MVRS as you are saying the variable you want to trim spaces against is in the mvrs

ChaitanyaILCR_1-1754931902379.png

 

 

function onSubmit() {
    g_form.setValue('variable_1', g_form.getValue('variable_1').trim());
}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Its not working chaitanya . It works only on portal if i submit from classis view its not working

Ankur Bawiskar
Tera Patron
Tera Patron

@Rajeevreddy 

why not add validation on change of that variable within MRVS?

OR

you can use onChange, trim the space and set the value again, but remember you are setting value again and onChange will trigger again so it should not go in loop

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Rajeevreddy 

Thank you for marking my response as helpful.

As per new community feature you can mark multiple responses as correct.

If my response helped please mark it correct as well so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader