cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Rob_CTL
Level: Powered On

SharePoint Text Field - Get Items - Limiting amount of text

Hi,

 

Is there a way of limiting how many characters are retrieved from a text field within SharePoint when using flow.

 

Issue:

SharePoint Get Items retrieves columns from SharePoint list, some of which are multi line text fields with a large quantity of text.  These items are then saved to an Excel sheet (for reporting purposes) but the large text fields cause the formatting of the Excel sheet to go mad i.e. huge row heights.  Is there a way to only only get (or put) the first 100 characters of a text field rather than all the contents?

 

Thanks

Rob

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: SharePoint Text Field - Get Items - Limiting amount of text

Try this

 

if(lessOrEquals(length(string(items('ApplyToEachItemAction')?['Comment'])), 100),items('ApplyToEachItemAction')?['Comment'],substring(items('ApplyToEachItemAction')?['Comment'],0,100))



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



View solution in original post

11 REPLIES 11
Super User
Super User

Re: SharePoint Text Field - Get Items - Limiting amount of text

Hi @Rob_CTL 

 

Map the column value using expression substring.

 

substring('test1234',0, 4)
 
Here the above expression returns 'test'
 
Thanks


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Rob_CTL
Level: Powered On

Re: SharePoint Text Field - Get Items - Limiting amount of text

@abm thanks for the reply.  That looks great but it appears to throw an error if the character count in the field is less that what is specified in the substring formula, is there anything I can do to get around that?

 

Thanks

Rob

Super User
Super User

Re: SharePoint Text Field - Get Items - Limiting amount of text

Hi @Rob_CTL 

 

So in that case you need use the length expression as well inside your substring.



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Community Support Team
Community Support Team

Re: SharePoint Text Field - Get Items - Limiting amount of text

Hi @Rob_CTL,

 

Yes, @abm 's advice is correct, if the length of these characters is less than 100, you can get it directly, or use the substring() function to get the first 100 characters.

 

About the condition determination method, you can use the condition action, or if() function, for example:

if(lessOrEquals(length('stringOfText'),100),'stringOfText',substring('stringOfText',0,100))

 

Best Regards,
Community Support Team _ Lin Tu

 

Rob_CTL
Level: Powered On

Re: SharePoint Text Field - Get Items - Limiting amount of text

Hi @v-litu-msft 

 

Thanks for the further explanation and the example function.  I am now looking to step this up a gear and running it within an "Apply to each" action.  This is proving a bit of a challenge as I have to get each item and I am struggling with the exact syntax to achieve this.

 

"Apply to each" action name = ApplyToEachItemAction

Column name = Comment

 

Function:

 

if(lessOrEquals(length(items('ApplyToEachItemAction')?['Comment'],100)),items('ApplyToEachItemAction')?['Comment'],substring(items('ApplyToEachItemAction')?['Comment'],0,100))

 

Any pointers gratefully received.

Rob

Super User
Super User

Re: SharePoint Text Field - Get Items - Limiting amount of text

Hi @Rob_CTL 

 

What error are you getting? Could you post a screenshot of your flow?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Rob_CTL
Level: Powered On

Re: SharePoint Text Field - Get Items - Limiting amount of text

Hi @abm 

 

Thanks for the reply

 

Flow:

flow-error2.png

 

flow-error3.png

Error that I'm receiving:

flow-error1.png

Thanks in advance

Rob

 

Super User
Super User

Re: SharePoint Text Field - Get Items - Limiting amount of text

Hi Rob,

 

Is comment is optional or mandatory?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Rob_CTL
Level: Powered On

Re: SharePoint Text Field - Get Items - Limiting amount of text

Hi @abm 


The field is optional.

 

Thanks
Rob

Super User
Super User

Re: SharePoint Text Field - Get Items - Limiting amount of text

Try this

 

if(lessOrEquals(length(string(items('ApplyToEachItemAction')?['Comment'])), 100),items('ApplyToEachItemAction')?['Comment'],substring(items('ApplyToEachItemAction')?['Comment'],0,100))



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



View solution in original post

Rob_CTL
Level: Powered On

Re: SharePoint Text Field - Get Items - Limiting amount of text

@abm  Genius! 👍

 

Thanks

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (5,029)