189
Views
6
Comments
Solved
ToUpper, ToLower, Substring,
Question

Hi guys

I'm getting the name inside a variable, but this variable receives the name completely capitalized

for example:variable Name: "JOHN BRIAN BECKSON" 


I'm using it in the following format:

ToUpper(Substr(Nome,0,1))+ToLower(Substr(Nome,1,Length(Nome)))


However, the response I am getting is the following:

"John brian beckson"

only the letter of the first name was converted and I wanted to convert the first letter to capital of each name, looking like this:

"John Brian Beckson"



2024-09-08 11-13-40
Nuno Damaso
 
MVP
Solution

Hi Fabiano, 

You can use the String_Split action from the text API (add as a dependency) using a space as a delimiter on your variable - this will get you a list of individual names [JOHN, BRIAN, BECKSON]. 

You can then use a for loop on this list and apply your function(toupper...to lower..) to each item. 

Finally you can use String_Join on this list to get your value back as a single string.


There are forge components available for this if you prefer: https://www.outsystems.com/forge/component-overview/5107/string-utils

On a side note, there's a c# method under the System Globalization namespace called "toTitleCase" that does just that if you care for making an extension for that: https://learn.microsoft.com/en-us/dotnet/api/system.globalization.textinfo.totitlecase

2023-10-21 19-42-11
Tousif Khan
Champion

Hello

You can achieve this using A JS if you are doing this on client side, There is a code snippet that is attached in a JS widget inside the client action,

You can write the same or modify there are plenty of available code if you see.

I am attaching you one sample and oml hope that might help you.

https://personal-ejuytnht.outsystemscloud.com/TestAppForm/SampleCapatalize?_ts=638358734462499820

I hope this help
Best Regards
Tousif Khan

Teststr_sample.oml
2023-12-16 19-57-03
Sanjay Kushwah

Hii @fabiano Pinto,

If you want to achieve this to show only on the UI, you can simply achieve this by apply the CSS on your expression.

text-transform: capitalize;


for example

span{

text-transform: capitalize; 

}


Thanks & Regards,

Sanjay Kushwah

2023-04-17 05-19-55
Vaishali Shrivastava

Hi @fabiano Pinto,


It is because this logic ToUpper(Substr(Nome,0,1))+ToLower(Substr(Nome,1,Length(Nome))) will convert only the 0th index value to upper case, that is, the letter J in your case, and will convert the rest of the string, starting from index 1 to the length of the string, to lower case.

Here, you can use the string split and String Join actions. You can take the dependency from the text API and use it for the conversion of the name.


I am adding a demo of what Nuno has suggested in case you need it. I hope it'll help you. 



Str_demo.oml
2023-09-06 07-26-35
Sudip Pal

Hi fabiano,

You can take look of the below post.

https://www.outsystems.com/forums/discussion/65183/convert-the-first-letter-with-upper-case/

It might help you.

Thanks & Regards,

Sudip Pal

UserImage.jpg
Mario Sepulveda

I would like to force my Label Value or Expression Value to always paint in the following format:


Example:

Itachi, Sasuke (NARUTO)


That is, I would like to do a CamelCase or Capitalize on all words before the "(" character. With the exception that after the "(" character, everything should be in capital letters.


Example:

ITACHI, SASUKE (naruto) --> Itachi, Sasuke (NARUTO)


Right now I have this in my Label Value:

ToUpper(Substr(displayname, 0, 1)) + ToLower(Substr(displayname, 1, Length(displayname) - 1))

And in my ExtendedClass property: "text-capitalize".


But it's not working for me.


Can someone help me?

Thank you!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.