Skip to main content

Notifications

Power Automate - Building Flows
Answered

Web Data Extraction // Data Type Conversion of extracted data to String

Posted on 21 Nov 2024 09:24:31 by 9
Hi there,
 
i'm fairly new to Power Automate Desktop and even though i was able to successfully build the flow i needed there is something i couldn't accomplish - and i'm convinced there has to be a simple solution that i'm just not aware of.
 
I'm using the Web Data Extract feature to read a list of HREF attributes of a link list on a web page.
Within a foreach loop i tried to apply string manipulations on the current item (which i expected to be a string) but always get a data type error (text functions not possible on ExternalObjects).
Same applies when i do extract a single web element's innerHTML to a variable.
 
Not a biggie, would typically just convert the variable to text and then manipulate it.
But i can't seem to find a way to convert a web extracted value to a string.
 
What i did to get my flow working was to write the extracted value/variable to an excel cell, read it again as single value from said cell, then it's data type became string and i was able to manipulate it before using further.
 
I'm quite sure there has to be a way more elegant method to perform the needed data type conversion :)
Does anyone have a solution for my problem? I've been searching the web for ages but could not manage to find one...
 
Thx a lot!
  • Verified answer
    OS-24101204-0 Profile Picture
    OS-24101204-0 9 on 22 Nov 2024 at 07:03:19
    Web Data Extraction // Data Type Conversion of extracted data to String
    Hi Eddy,
     
    thank you for responding to my question - unfortunately that didn't solve my Problem or provide a solution.
    Subborn as i am i couldn't leave the topic alone and i finally found the explanation/solution on my own:
     
    First: PAD Workflows differ concerning variable notation, depending if Power FX is activated or not.
     
    The Web Data Extract connector always creates a data table object, even if only a single value is extracted (as for example an innerHTML of a div element). Even when a list of entries is extracted - like the link list in my original post - the generated object is always a data table, not a data list object.
     
    To directly access the values it's necessary to double index the query as in 2-dimensional arrays.
    Given the extracted data was saved in the default variable DataFromWebPage and no foreach loop is used:
     
    Without Power FX
    %DataFromWebPage[0][0]%
     
    With Power FX
    =Index(Index(DataFromWebPage, 1), 1)
     
    Accordingly when using a foreach loop on the DataFromWebPage object (which of course creates a data list object, default name is CurrentItem):
     
    Without Power FX
    %CurrentItem[0]%
     
    With Power FX:
    =Index(CurrentItem, 1)
     
    Hopefully this will help other new Power Automate'rs saving valuable time on this topic.
     
    TGF, have a nice weekend & Best Regards
    Oliver
  • Suggested answer
    Eddy Wu Profile Picture
    Eddy Wu 17 on 21 Nov 2024 at 10:21:46
    Web Data Extraction // Data Type Conversion of extracted data to String

    Hi,

    I suggest using the "Get Details of Element on Web Page" function to retrieve the innerHTML or HREF directly from the element.

    Additionally, if you still need to convert the variable, you can use the "Convert Custom Object to JSON" function to extract and adjust the required attributes.

    If this resolves your question, please mark it as answered and consider giving it a Like.

    Best regards,
    Eddy

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

October 2024 Newsletter…

October 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #4 How to Conntact Support…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,081

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,795

Leaderboard