Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Expressions works in Condition, not as trigger

(0) ShareShare
ReportReport
Posted on by 22

Hi All,

I'm trying to define a trigger condition, to make the flow run only when the filename contains the string "Uren". The expression I wrote works as a Condition Action, but returns and error when set as trigger condition. If I understand the error correctly, it's trying to read the filename before it's present in the flow, returning a null. How can I fix this?

 

Expressions:  contains( base64ToString(triggerOutputs()?['headers/x-ms-file-name-encoded']),'Uren')

 

Error: InvalidTemplate. Unable to process template language expressions for trigger 'When_a_file_is_created_or_modified_in_a_folder' at line '1' and column '16216': 'The template language function 'base64ToString' expects its parameter to be a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#base64ToString for usage details.'.

 

The flow:

flow with error.jpg

  • Stefanovic83 Profile Picture
    22 on at
    Re: Expressions works in Condition, not as trigger

    So is the logic then like this?

     

    When "Uren.xlsx is modified, the condition trigger returns 'Uren'. 

    When something else is modified, the conditrion trigger returns null

  • v-bofeng-msft Profile Picture
    on at
    Re: Expressions works in Condition, not as trigger

    Hi @Stefanovic83 ,

     

    Cause null value causes an error (base64ToString cannot handle null values), So I add conditional statements to circumvent triggerOutputs()? ['headers/x-ms-file-name-encoded']) If it is empty, it will be no error.

     

    Best Regards,

    Bof

  • Stefanovic83 Profile Picture
    22 on at
    Re: Expressions works in Condition, not as trigger

    Yeah that works @Shuvam-rpa . I just don't understand yet why. Could you explain? 

     

    The only difference is you adding that first part of the statement:

     

    @if(empty(triggerOutputs()?['headers/x-ms-file-name-encoded']),false,contains( base64ToString(triggerOutputs()?['headers/x-ms-file-name-encoded']),'Uren'))

  • Verified answer
    v-bofeng-msft Profile Picture
    on at
    Re: Expressions works in Condition, not as trigger

    Hi @Stefanovic83 ,

     

    Please try:

     

    @if(empty(triggerOutputs()?['headers/x-ms-file-name-encoded']),false,contains( base64ToString(triggerOutputs()?['headers/x-ms-file-name-encoded']),'Uren'))

     

    Best Regards,

    Bof

  • Stefanovic83 Profile Picture
    22 on at
    Re: Expressions works in Condition, not as trigger

    Thanks @Shuvam-rpa but my question was for the expression for the trigger condition.

    I got already the flow working using an action Condition. 🙂 

     

  • Shuvam-rpa Profile Picture
    891 Super User 2024 Season 1 on at
    Re: Expressions works in Condition, not as trigger

    @Stefanovic83 kindly use below expression

    contains(triggerOutputs()?['headers']?['x-ms-file-name'],'Uren')
     
    please check below screenshot for reference
     
    Shuvamrpa_0-1657179491165.pngShuvamrpa_1-1657179495765.png

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

     
     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1