cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kudo Kingpin
Kudo Kingpin

Returning sharepoint search results to powerapps from flow

I would like to be able to call the sharepoint search rest api  from my powerapps using flow.

 

I have a  standalone app that displays data from a list with many fields in a gallery. I want to be able to filter the items in the list based on a sharepoint search query. (i.e. I want to be able to let the user enter CustomerName=Contos* and have the view show only records where the field CustomerName  begins with ‘Contos’.

The powerapps search function works, but it queries all fields. I want to query on Specific fields using the search API.

I want to be able to call a flow, passing in the search query string ‘CustomerName=Contos*’  and the list of fields to return, and have the flow  call the sharepoint search API (_api/search/postquery)  and return the data in tabular format so that the gallery control can just switch between using list data and search results.

 

I  got it working by looping through all the results in @body('SPSearch')?['d']?['postquery']?['PrimaryQueryResult']?['RelevantResults']?['Table']?['Rows']?['results'] and then for each row looping through all of the columns and setting a temporary field to the value for that column, but it takes 10 minutes to run a simple query (because of the work being done in the for loop).

 

The issue is that the results from search look like this:

"results": [

    {

      "__metadata": {

        "type": "SP.SimpleDataRow"

      },

      "Cells": {

        "results": [

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Rank",

            "Value": "27.591251373291",

            "ValueType": "Edm.Double"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "DocId",

            "Value": "17594549904503",

            "ValueType": "Edm.Int64"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Title",

            "Value": "TiO2_BCN - GR Nanomaterials - V. Mathur",

            "ValueType": "Edm.String"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ListItemID",

            "Value": "5678",

            "ValueType": "Edm.String"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Created",

            "Value": "2014-06-27T14:46:49.0000000Z",

            "ValueType": "Edm.DateTime"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "IsClosedOWSCHCS",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ContactEmailAddressOWSTEXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "CompanyOWSTEXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "RequestTextOWSMTXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ResponseTextOWSMTXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "_ranking_features_",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "PartitionId",

            "Value": "9eec07e6-f6f8-4e24-b4c7-c5868500b417",

            "ValueType": "Edm.Guid"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "UrlZone",

            "Value": "0",

            "ValueType": "Edm.Int32"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Culture",

            "Value": "en-US",

            "ValueType": "Edm.String"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ResultTypeId",

            "Value": "0",

            "ValueType": "Edm.Int32"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "RenderTemplateId",

            "Value": "~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Default.js",

            "ValueType": "Edm.String"

          }

        ]

      }

    },

    {

      "__metadata": {

        "type": "SP.SimpleDataRow"

      },

      "Cells": {

        "results": [

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Rank",

            "Value": "27.5383605957031",

            "ValueType": "Edm.Double"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "DocId",

            "Value": "17621262638504",

            "ValueType": "Edm.Int64"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Title",

            "Value": "Prochazka, Jan ADVANCED MATERIALS JTJ",

            "ValueType": "Edm.String"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ListItemID",

            "Value": "26",

            "ValueType": "Edm.String"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Created",

            "Value": "2011-02-21T22:12:36.0000000Z",

            "ValueType": "Edm.DateTime"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "IsClosedOWSCHCS",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ContactEmailAddressOWSTEXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "CompanyOWSTEXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "RequestTextOWSMTXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ResponseTextOWSMTXT",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "_ranking_features_",

            "Value": null,

            "ValueType": "Null"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "PartitionId",

            "Value": "9eec07e6-f6f8-4e24-b4c7-c5868500b417",

            "ValueType": "Edm.Guid"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "UrlZone",

            "Value": "0",

            "ValueType": "Edm.Int32"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "Culture",

            "Value": "en-US",

            "ValueType": "Edm.String"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "ResultTypeId",

            "Value": "0",

            "ValueType": "Edm.Int32"

          },

          {

            "__metadata": {

              "type": "SP.KeyValue"

            },

            "Key": "RenderTemplateId",

            "Value": "~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Default.js",

            "ValueType": "Edm.String"

          }

        ]

      }

 

  ]

 

Anyone have any ideas how to turn the search results in the above  format into a regular ‘flat’  array  so that it can be returned to powerapps?

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Returning sharepoint search results to powerapps from flow

I just found that search DOES let me choose which column to search . Still would be valuable to use SP search engine for more complex searches though and would help avoid delegation issues.

View solution in original post

3 REPLIES 3
Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Returning sharepoint search results to powerapps from flow

I just found that search DOES let me choose which column to search . Still would be valuable to use SP search engine for more complex searches though and would help avoid delegation issues.

View solution in original post

Highlighted
Community Support
Community Support

Re: Returning sharepoint search results to powerapps from flow

 

Hi @RussellGove ,

 

Have you found a suitable solution? If so, please click "Accept as Solution" on the reply that describes how describes you were able to solve your issue!

In addition, perhaps you could try to use the action Parse JSON-Filter array to achieve the need to filter the array.

Please check this article and see if it helps:

http://johnliu.net/blog/2018/6/a-thesis-on-the-parse-json-action-in-microsoft-flow

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Returning sharepoint search results to powerapps from flow

Hey, Someone figured out how to do this and posted the solution at https://buildbod.com/2018/10/29/sharepoint-search-results-as-a-csv-file-using-microsoft-flow/

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Users online (6,584)