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.
Solved! Go to Solution.
Hi @OlafStetzer ,
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']),'_'))
Best regards,
Mabel
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.
Hi @OlafStetzer ,
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']),'_'))
Best regards,
Mabel
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.
Check out new user group experience and if you are a leader please create your group
See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.
User | Count |
---|---|
33 | |
10 | |
8 | |
7 | |
5 |
User | Count |
---|---|
51 | |
22 | |
12 | |
11 | |
9 |