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 / Trying to extract ids ...
Power Automate
Answered

Trying to extract ids from SharePoint folder Names: The value cannot be converted to the target type.

(0) ShareShare
ReportReport
Posted on by 145

Hello,
I setup a flow to extract ids from folders that all share the same display name format of 'Country Name - CountyAssignedID', with the exception of some having an additional hypen '-', so 'County Name - Additional Name - CountyAssignedID'. Each of the country assigned ids have leading zeros. Example: 'Harris - County - 00260002'. The goal of my flow is to extract the country assigned id without any leading zeros and compare it against a given id inputted in my manual trigger form, which I have accomplished for the majority of the folder names, but just recently noticed that some (small pool) are failing and resulting in this error: 

"The execution of template action 'Filter_array_2' failed: The evaluation of 'query' action 'where' expression '@equals(int(replace(substring(item()?['DisplayName'], add(lastindexOf(item()?['DisplayName'], '-'), 2), sub(length(item()?['DisplayName']), add(lastindexOf(item()?['DisplayName'], '-'), 2))), '^0+', '')), int(replace(outputs('input_countyName'), '[^a-zA-Z0-9 ]+', '')))' failed: 'The template language function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type."


Not sure how to resolve this considering most of them are working, its just a small handful of them that are failing. I did attempt to go through and rename each folder that failed to ensure there were no special characters that I could be missing but that didnt resolve the issue. Any suggestions? 


Categories:
I have the same question (0)
  • Jdelavega Profile Picture
    106 on at

    Hi @Alanisp22 

     

    It seems that there is an issue with the input parameters being used in the template action 'Filter_array_2'. Specifically, the template is trying to convert a value to an integer using the 'int' function, but the value is not in a valid format for conversion.

     

    I think you should review the input parameters being used in the 'Filter_array_2' action and make sure that the data types match what is expected by the function.

  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    Can you try the following expression instead and see how it goes.

     

    //Using DisplayName as per your example
    int(trim(last(split(item()?['DisplayName'], '-'))))
    
    //It might be better to use {Name} instead of DisplayName
    int(trim(last(split(item()?['{Name}'], '-'))))
    
    //Example below would return the number 260002
    int(trim(last(split('Harris - County - 00260002', '-'))))

     

    If you still have issues, I'd check the hyphens used in the ones that are failing - they can be encoded differently if pasting from Word for example.

  • Alanisp22 Profile Picture
    145 on at

    Thank you!!!

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…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 398 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 331 Super User 2025 Season 2

#3
Expiscornovus Profile Picture

Expiscornovus 203 Most Valuable Professional

Last 30 days Overall leaderboard