web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Substring takes 0 as S...
Power Automate
Unanswered

Substring takes 0 as StartIndex, but doesnt take more than 0 as StartIndex

(0) ShareShare
ReportReport
Posted on by

Hey Team,

 

I want to remove the first 29 characters of the email and save it in the sharepoint folder as new emails come in.

 

When I try to use Substring, it throws me this error.

 

Unable to process template language expressions in action 'Remove_Pretext' inputs at line '1' and column '23468': 'The template language function 'substring' parameters are out of range: 'start index' and 'length' must be non-negative integers and their sum must be no larger than the length of the string. Please see https://aka.ms/logicexpressions#substring for usage details.'.

 

 

This is my substring function

 

substring(variables('Filename'),29,length(variables('Filename')))

 

 

It works with 0 as the StartString, but not > 0.

yasskal_0-1612238530170.png

 

Works fine until removing the pretext part where there is the substring function.

 

Categories:
I have the same question (0)
  • Mira Ghaly Profile Picture
    11,413 Moderator on at

    @Anonymous 

    If you need first 29 characters use below

    :

    substring(variables('Filename'),0,28) 

  • Community Power Platform Member Profile Picture
    on at

    Hey @Mira_Ghaly ,

     

    I need to remove the first 29 Characters. "Rpt1000000528_20210103230011"_FILENAME.xlsx

     

    substring(variables('Filename'),0,length(variables('Filename'))) - This works

     

    substring(variables('Filename'),29,length(variables('Filename'))) - This doesnt work

  • Mira Ghaly Profile Picture
    11,413 Moderator on at

    @Anonymous 

    Yeah I got you wrong please use

    substring(variables('Filename'),29,length(variables('Filename'))-1)

     

  • Community Power Platform Member Profile Picture
    on at

    @Mira_Ghaly 

    I tried that as well.

     

    substring(variables('Filename'),29,sub(length(variables('Filename')),1))
     
    Tried subtracting the filename length by 1. I think the final index is correct, because it works with 0 to the (length of file -1), doesnt work if the index is set greater than 0.
     
    I also have a condition if the filename ends with ".xlsx" to make sure that there is a filename
     
  • Verified answer
    Mira Ghaly Profile Picture
    11,413 Moderator on at

    @Anonymous 

    I got the issue: 

     
    This worked for me
     
    substring(variables('FileName'),28,sub(length(variables('FileName')),28))
  • Community Power Platform Member Profile Picture
    on at

    Thank you! 🙂 This worked!

  • Community Power Platform Member Profile Picture
    on at

    Getting error - The 'start index' for function 'substring' must be equal to or greater than zero and must be less than '0' which is the length of the string.

    On split(substring(variables('BidderString'),0,outputs('Compose')),',')

    Please help

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard