White Spaces & Lowercase

Bhadley
Kilo Expert

Hi All,

 

Was hoping I could get a bit of advice on how I could pull this off. My end goal is to be able to get rid of all white spaces and turn a string into all lowercase and want to see what might be the best way to do this with my current setup.

 

I have a Service Catalog form that launches into a workflow. In the workflow I have it create a ticket in a new table I created for employees. The workflow generates a EMP ticket using the Create Task function on the table and I use         task.u_first_name = current.variables.first_name;     to pull the variables from the catalog form into the appropriate fields of the new task. I am not too concern on the catalog form itself but during this point of Task Creation I would like to have it convert some of the fields such as firstname, lastname, etc into lowercase as well as get rid of any White Spaces that were added to the end when the user was copy\pasting information into the form.

 

I was playing around with some javascript with the toLowerCase(); function but it didn't seem to like that within the Task Creation function of the workflow. Also tried to play around with some onLoad client script on the form itself without much luck. Would appreciate if anyone has needed to do this before or have any ideas on how I can tackle this issue. Thanks a bunch!

1 ACCEPTED SOLUTION

casey_stinnett
Giga Expert

To be extra sure that all white spaces are gone, all letters are lower case, and there are no white spaces trailing, then you can this this on your variable:



var variable = variable.toString().toLowerCase().replace(/\s/g, '').trim();



Does this help?



What error did you get when you used toLowerCase() before?


View solution in original post

3 REPLIES 3

ohhgr
Kilo Sage
Kilo Sage

Hi Bhadley,



Javascript functions toLowerCase() and trim() should do the trick for you. Just make sure that you explicitly convert the variable into a string by using a toString() method.



Let me know if it's not working for you.



Thanks,
Mandar


casey_stinnett
Giga Expert

To be extra sure that all white spaces are gone, all letters are lower case, and there are no white spaces trailing, then you can this this on your variable:



var variable = variable.toString().toLowerCase().replace(/\s/g, '').trim();



Does this help?



What error did you get when you used toLowerCase() before?


It's definitely a Monday. I was missing the toString function to properly carry the javascript. On the Create Task function within the workflow I was able to use;



var firstname = current.variables.first_name;


var u_first_name = firstname.toString().toLowerCase().replace(/\s/g, '').trim();


task.u_first_name = u_first_name;



This cut out the white spaces and convert the current variable to lowercase before writing it to the ticket. Thanks for putting me down the correct path on this one, i really appreciate it!