Search code examples
powerappspower-automatepower-automate-desktop

How can I include \n in this formula to substrate this text (I'm close)


I have this string contained in a mail:

CO NIV ICE REFRESCOS DE SOYA has started successfully.CO NIV ICE REFRESCOS DE SOYA

User
    juan.lopez@mail.com

Parameters
    output = 7
    country = 170
    period = 202204012
    DATA_REPORT_DELIVERY = NO
    read_persistance = YES
    write_persistance = YES
    client = 18277
    indicator_group = SALES


Executed tasks

My desired output is: 202204012.

I use this type of formula to extract other values successfully but I didn't get why Period doesn't work as expected:

trim(first(split(last(split(body('Html_to_text'),'period = ')),'DATA')))

Then, my obtained output (in raw format) is:

"CO NIV ICE REFRESCOS DE SOYA has started successfully.CO NIV ICE REFRESCOS DE\nSOYA User juan.perez@mail.com Parameters output = 7 country = 170 period\n= 202204012"

While other variables such as output or country work fine and the extraction is correct. I can extract, for example, the 7to output and the 170to country.

With this little modification (eliminate the spaces and = sign), the output is near to the expected result:

trim(first(split(last(split(body('Html_to_text'),'period')),'DATA')))

My result obtained with this, are this:

= 202204012

Perspective

I mean. If I understand well, I should obtain the value between" period = and DATA_REPORT_DELIVERYas the other variables.

The 'Html_to_text' raw output looks like this:

"body": "CO NIV ICE REFRESCOS DE SOYA has started successfully.CO NIV ICE REFRESCOS DE\nSOYA User juan.perez@mail.com Parameters output = 7 country = 170 period\n= 202204012 DATA_REPORT_DELIVERY = NO read_persistance = YES write_persistance =\nYES client = 18277 indicator_group = SALES Executed tasks 

I don't know how can I include the "\n" into the formula.

Thank you all for the support.


Solution

  • I replace the \n for ;. It make this so much easier.

    1. I create a Compose to my Html_to_text body.

    2. I replace the \n with this formula: replace(outputs('Compose'),decodeUriComponent('%0A'),';')

    3. I substitute the output. Finally, I use this formula:

      trim(first(split(last(split(outputs('Replacing'),'period;= ')),'DATA')))

    It works.