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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Compose returns wrong ...
Power Automate
Unanswered

Compose returns wrong data in Power Automate

(1) ShareShare
ReportReport
Posted on by 32

Hi guys!
I´m trying that a compose action returns the subject email, but not completed, and example could be like this:
If and email arrives with this subject - Test 13 PM Stage3, then i want that the compose returns Test 13.
but if the subject email is Test PM Stage3, then the compose return Test.
I have a function in the compose:

if(
    or(
        equals(length(split(toLower(triggerOutputs()?['body/subject']), '[_/\\s-]')), 4),
        equals(length(split(toLower(triggerOutputs()?['body/subject']), '[_/\\s-]')), 5)
    ),
    concat(
        split(toLower(triggerOutputs()?['body/subject']), '[_/\\s-]')[0],
        ' ',
        coalesce(split(toLower(triggerOutputs()?['body/subject']), '[_/\\s-]')[1], '')
    ),
    first(split(toLower(triggerOutputs()?['body/subject']), ' '))
)
 
But when i receive and email with the first example i give you (Test 13 PM Stage13), it returns to me only "Test".

Luilui8090_1-1705104057671.png

 

I´ll give a little bit more of context, I want that if the first word of the email subject is text and the second one is a number, then the compose returns to me this two values.
Example Email Subject - Test 1313 PM Stage 15
Returns - Test 1313
But if the first condition is not correct, then returns only the first word of the subject.
Example Email Subject - Test PM Stage 15
Returns - Test

Categories:
I have the same question (0)
  • sandeepstw Profile Picture
    312 Moderator on at

    Hi @Luilui8090 ,

     

    User this code in compose action - 

     

    if(
     and(
     equals(split(triggerOutputs()?['body/subject'], ' ')[0], 'Test'),
     isNumeric(split(triggerOutputs()?['body/subject'], ' ')[1])
     ),
     concat(
     split(triggerOutputs()?['body/subject'], ' ')[0], 
     ' ', 
     split(triggerOutputs()?['body/subject'], ' ')[1]
     ),
     first(split(triggerOutputs()?['body/subject'], ' '))
    )

     

     

    Please give kudos and mark as solution if it helps.  

      

    Thanks, 

    Sandeep Mishra 

  • Luilui8090 Profile Picture
    32 on at

    But how can I use this code if the subject always change in every email that arrives.

    So the subject could be different, it don’t always need to be “Test” in my subject, this could be change when an email arrives, as the numerical word.

     

  • sandeepstw Profile Picture
    312 Moderator on at

    Please elaborate your subject condition what ever it could be. 

  • Luilui8090 Profile Picture
    32 on at

    Of course! 😄 

    The subject can be anything, there is no specific one.
    The function in the compose must do the following:
    If the second word or fragment of the subject is numeric, then return the first two words or fragments of the subject.
    If this condition is not met, it should only return the first word or fragment of the subject.

    Example of a subject:

    Charlie 567 MX Stage4

    The condition should return:

    Charlie 567

    If the subject were:

    Charlie MX Stage4

    The condition should return:

    Charlie

  • VictorIvanidze Profile Picture
    13,079 on at

     

    if(
     and(
     greater(length(split(triggerOutputs()?['body/subject'], ' ')), 1),
     isInt(split(triggerOutputs()?['body/subject'], ' ')[1])
     ),
     concat(
     split(triggerOutputs()?['body/subject'], ' ')[0], 
     ' ', 
     split(triggerOutputs()?['body/subject'], ' ')[1]
     ),
     split(triggerOutputs()?['body/subject'], ' ')[0]
    )

     

  • sandeepstw Profile Picture
    312 Moderator on at

    HI @Luilui8090 ,

     

    Use this expression - 

    if(
     isNumeric(split(triggerOutputs()?['body/subject'], ' ')[1]),
     concat(split(triggerOutputs()?['body/subject'], ' ')[0], ' ', split(triggerOutputs()?['body/subject'], ' ')[1]),
     first(split(triggerOutputs()?['body/subject'], ' '))
    )
  • Luilui8090 Profile Picture
    32 on at

    I got this error in my function with your code 

    Luilui8090_0-1705184500197.png

     

     

  • Luilui8090 Profile Picture
    32 on at

    I got this error in my function with your code 

    Luilui8090_0-1705184500197.png

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 605

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard