cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
marial16
Post Partisan
Post Partisan

get first 99 characters from string and concat

 Hallo,

i have an issue where the email subject in a flow must not be >100 characters.

so when an item is created i want to set the t\Title field in a variable .

then i use an expression which however returns a random string and not the first 99 characters concatenated with '...'

 

if(greater(length(variables('var_Title')),100),concat(substring(variables('var_Title'),99),'...'),variables('var_Title'))

 

The flow does not fail as before but i want the correct subject

Any ideas ?

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

The substring expression accepts three parameters:

  1. The string that you want to extract something from.
  2. The start position that you want to begin extraction.
  3. Optional length parameter.

Your expression:

 

if
(
  greater(length(variables('var_Title')),100),
  concat(substring(variables('var_Title'),99),'...'),
  variables('var_Title')
)

 

You are specifying only two parameters which means the substring is starting at position 99 and continuing until the end of the string, and then appending "...". You perhaps want it like this:

 

if
(
  greater(length(variables('var_Title')),100),
  concat(substring(variables('var_Title'),0,99),'...'),
  variables('var_Title')
)

 

But you also said the subject must not be more than 99 characters, 99+3 is 102, so perhaps you only want to capture the first 66 characters? Anyway, this should fix your issue.

 

View solution in original post

4 REPLIES 4
annajhaveri
Community Champion
Community Champion

@marial16 , the expression looks correct to get the first 99 characters and append '...' to it, what result does do you get out of it?

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Instead of getting for example:

TextTexttexttextedfhdivbdsjhvdddvbd.....

 

i get the final  dddvbd..... characters.

i Apologize for the random data . i hope its clear

 

Paulie78
Super User
Super User

The substring expression accepts three parameters:

  1. The string that you want to extract something from.
  2. The start position that you want to begin extraction.
  3. Optional length parameter.

Your expression:

 

if
(
  greater(length(variables('var_Title')),100),
  concat(substring(variables('var_Title'),99),'...'),
  variables('var_Title')
)

 

You are specifying only two parameters which means the substring is starting at position 99 and continuing until the end of the string, and then appending "...". You perhaps want it like this:

 

if
(
  greater(length(variables('var_Title')),100),
  concat(substring(variables('var_Title'),0,99),'...'),
  variables('var_Title')
)

 

But you also said the subject must not be more than 99 characters, 99+3 is 102, so perhaps you only want to capture the first 66 characters? Anyway, this should fix your issue.

 

Looks like it solved the issue.

Thank you all

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (1,755)