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 / trim function not work...
Power Automate
Unanswered

trim function not working on empty string

(0) ShareShare
ReportReport
Posted on by

Hello,

 

I am using (or trying to use) the trim function in combination with the result of an approval,
specifically the comment. Now it seems that the function throws an error when there is no comment, e.g.
the function has to operate on an empty string. Is there a good workaround for this?

This is my current code:

if(equals(length(trim(body('Aktualisiertes_Approval_aus_Logliste_abrufen')?['Approver_Kommentar'])),0),'',concat('_',trim(body('Aktualisiertes_Approval_aus_Logliste_abrufen')?['Approver_Kommentar']),'_'))

The purpose of the function is to add the comment to a string with markup: _approver comment_

But since this does not work with empty strings, the _ _ shall be omitted in this case.

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    68,697 Most Valuable Professional on at

    I know its going to legthen the function, but I suspect you are going to need to enclose this (or parts of it) inside an If(isblank(body('Aktualisiertes_Approval_aus_Logliste_abrufen')?['Approver_Kommentar']),true function, false function) to test for a blank comment before processing the Trim.

  • Verified answer
    v-yamao-msft Profile Picture
    on at

    Hi @Anonymous ,

     

    Do you want to concat the approval comments with other characters if it is not empty?

     

    Please consider using an empty function to check if the comment is empty or not, then combine with other characters depends on situation.

     

    I have configured the flow likes below for your reference:

    if(empty(items('Apply_to_each')?['comments']),'',concat('_',trim(items('Apply_to_each')?['comments']),'_'))

    1.PNG

     

    Best regards,

    Mabel

     

  • Community Power Platform Member Profile Picture
    on at

    Thank you. It is in fact not the isblank function (this does not exist) but the empty function.

     

    Yes the function gets really lng this way nad the little editor window for functions does not make it easy to edit long functions either. But it works now.

     

    What I do not understand: Why is Micrsoft not able to programm this and other functions in a way that they are more robust. E.g. a string function should still work on empty strings, just do nothing. Flow is considered as a end user programming environment so end users should not be bothered with exceptions handling where it can be avoided.

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard