How to Get First 15 letters from a sentence


Badge +4

For example if i have a company name: Aeronautical Machine Transportation and Repair Company PVT. LTD.

From above example i would like to get only first 15 letters in all capital letters including space "AERONAUTICAL MACH" or i am not sure if space is also counted as a letter?


10 replies

Userlevel 7
Badge +17

Hi!

Are you using Nintex Forms in your solution? Is the company name being there provided by a user, using a form? If so, you could use inline functions in Nintex Form, to dynamically calculate the information you need, using the PadLeft and ToUpper functions: http://help.nintex.com/en-US/o365/#o365/O365Forms/ReferenceOther/Inlinefunctionsprovided.htm then to save the outcome in another field of your choice.

On the other hand, if you don't use Forms, Nintex Workflow for O365 doesn't have inline functions yet sad.png To get the first 15 characters out of your string you should then create an integer variable having its default value = 0, a loop with a condition to run until the variable is equal or greater 15, then in each run get the substring from a string starting on position indicated by the variable and having length = 1. The append such extracted character to a string variable of your choice. This approach will let you to get first 15 characters, however won't capitalize them. I have no better idea for capitalization better than having a replace action replacing each lowercase letter with its uppercase counterpart.

Regards,

Tomasz

Userlevel 4
Badge +7

Hi Bhashwar Bhattarai

My approach would be to use the inline function substring:

fn-ToUpper(fn-Substring(Your String,Index to start,number of characters))

fn-ToUpper(fn-Substring(Aeronautical Machine Transportation and Repair Company PVT. LTD,0,15))

which would give you

AERONAUTICAL MA

You would just need to change the number of characters to return to get your desired result

Hope this helps

Userlevel 7
Badge +17

‌ you are correct but only when talking about the on premise Nintex. As I wrote above - inline functions are not available for Nintex Workflow in Office 365, so that will not work. However, such construction can be used in Nintex Forms even in Office 365, as mentioned above again happy.png

Regards,

Tomasz

Userlevel 4
Badge +7

Hi

Don't disagree with anything you wrote, I just couldn't get PadLeft to work for a number of characters, I have used that to add spaces or leading zeros. Substring is how I would approach it. Hope I didn't offend

Userlevel 7
Badge +17

What I meant in general is that your approach is not possible in Nintex Workflow for Office 365 because there are no inline functions sad.png So your solution is perfect, but not for the Office 365 sad.png

Userlevel 4
Badge +7

Tomasz Poszytek

Still fully on prem sorry!!! does regex work??

^.{0,15}

would do the same

Userlevel 7
Badge +17

No problem happy.png

The regex! Very smart approach. I like it. Simple and fast.

The last thing to solve then is how to uppercase the string happy.png

Badge +4

Thank you Tomasz for your reply,

While creating a question i did not see an option to categorize this question as a SharePoint on prem, and we do have an on prem environment.

The solution provided by Paul worked perfectly, and i am pretty sure we could use various methods and the method provided by you will work as well.

Badge +4

Thank you Paul,

Your solution hit the nail in the head. I was trying to do a SQL insert and the column (sort name) that came from name has max 15 varchar length. happy.png

Userlevel 7
Badge +17

No problem. I moved it into the "on prem" forum happy.png

Reply