How to use optional parameters of Dataverse Search in Power Automate Flow?

By | February 2, 2023

As demonstrated in our previous blog, we can use the Dataverse search in Power Automate Flow comfortably. In this blog, we will have a look at how the optional parameters are used to limit the search as per our requirements. So, let’s dive in without further ado.

To quickly revise everything that we have discussed in the previous blog, below is an example to use the search API to find all the entities which have “Jim” somewhere in their indexed fields.

Power Automate Flow

Now, the successful response will consist mainly of three things –

  • Value
    • An array of all the matching records. By default, 50 rows are returned but can be changed from 1 to 100 using the Top
  • Total Record Count
    • Returns the total number of matching records if the parameter is set to true. By default, will always be false and return -1.
  • Facets
    • The results of the facet parameter i.e. additional filtering on the received search results.

It will look like this –

{

"querycontext": null,

"value": [

{

"@search.score": 8.406683,

"@search.highlights": {

"firstname": [

"{crmhit}Jim{/crmhit}"

],

"fullname": [

"{crmhit}Jim{/crmhit} Harper"

]

},

"@search.entityname": "contact",

"@search.objectid": "c8dbc8c3-0c9a-ed11-aad0-002248cc94a7",

"@search.objecttypecode": 2,

"fullname": "Jim Harper",

"versionnumber": 1279956,

"statecode": [

"Active"

],

"statuscode": [

"Active"

],

"entityimage_url": null,

"createdon": "1/22/2023 4:25 AM",

"modifiedon": "1/22/2023 4:25 AM",

"emailaddress1": "JimOHarper@dayrep.com",

"address1_city": "Detroit",

"address1_telephone1": null,

"parentcustomerid": null,

"parentcustomeridname": null,

"telephone1": "313-461-8718"

},

{

"@search.score": 7.212613,

"@search.highlights": {

"firstname": [

"{crmhit}Jim{/crmhit}"

],

"fullname": [

"{crmhit}Jim{/crmhit} Glynn (sample)"

]

},

"@search.entityname": "contact",

"@search.objectid": "f3baf772-9192-ed11-aacf-6045bd44fb6c",

"@search.objecttypecode": 2,

"fullname": "Jim Glynn (sample)",

"versionnumber": 1075816,

"statecode": [

"Active"

],

"statuscode": [

"Active"

],

"entityimage_url": "/Image/download.aspx?Entity=contact&Attribute=entityimage&Id=f3baf772-9192-ed11-aacf-6045bd44fb6c&Timestamp=638091357298094244",

"createdon": "1/12/2023 3:55 PM",

"modifiedon": "1/12/2023 3:55 PM",

"emailaddress1": "someone_j@example.com",

"address1_city": "Renton",

"address1_telephone1": null,

"parentcustomerid": "dfbaf772-9192-ed11-aacf-6045bd44fb6c",

"parentcustomeridname": "Coho Winery (sample)",

"@search.parentcustomerid.logicalname": "account",

"telephone1": "555-0109"

},

{

"@search.score": 5.5241776,

"@search.highlights": {

"name": [

"{crmhit}Jim's{/crmhit} Accounting"

]

},

"@search.entityname": "account",

"@search.objectid": "9014d333-0e9a-ed11-aad0-002248cc94a7",

"@search.objecttypecode": 1,

"name": "Jim's Accounting",

"versionnumber": 1280040,

"statecode": [

"Active"

],

"statuscode": [

"Active"

],

"entityimage_url": null,

"createdon": "1/22/2023 4:35 AM",

"modifiedon": "1/22/2023 4:35 AM",

"emailaddress1": null,

"address1_city": null,

"accountnumber": null,

"primarycontactid": null,

"primarycontactidname": null,

"telephone1": null

}

],

"facets": {},

"totalrecordcount": -1

}

There are some additional optional parameters as well which you can use –

entities – This is an optional parameter to restrict the search results to a limited number of entities instead of searching through all the entities which have Dataverse search configured. The logical names of the entities must be provided. The syntax is as follows –

Power-Automate-Flow

returntotalrecordcount – This is an optional parameter of type Boolean. If set to true, will return the total count of search results. By default, it is set to false and will return -1. The syntax is as below –

Power Automate Flow

{

"querycontext": null,

"value": [

{

"@search.score": 8.406683,

"@search.highlights": {

"firstname": [

"{crmhit}Jim{/crmhit}"

],

"fullname": [

"{crmhit}Jim{/crmhit} Harper"

]

},

"@search.entityname": "contact",

"@search.objectid": "c8dbc8c3-0c9a-ed11-aad0-002248cc94a7",

"@search.objecttypecode": 2,

"fullname": "Jim Harper",

"versionnumber": 1279956,

"statecode": [

"Active"

],

"statuscode": [

"Active"

],

"entityimage_url": null,

"createdon": "1/22/2023 4:25 AM",

"modifiedon": "1/22/2023 4:25 AM",

"emailaddress1": "JimOHarper@dayrep.com",

"address1_city": "Detroit",

"address1_telephone1": null,

"parentcustomerid": null,

"parentcustomeridname": null,

"telephone1": "313-461-8718"

},

{

"@search.score": 7.212613,

"@search.highlights": {

"firstname": [

"{crmhit}Jim{/crmhit}"

],

"fullname": [

"{crmhit}Jim{/crmhit} Glynn (sample)"

]

},

"@search.entityname": "contact",

"@search.objectid": "f3baf772-9192-ed11-aacf-6045bd44fb6c",

"@search.objecttypecode": 2,

"fullname": "Jim Glynn (sample)",

"versionnumber": 1075816,

"statecode": [

"Active"

],

"statuscode": [

"Active"

],

"entityimage_url": "/Image/download.aspx?Entity=contact&Attribute=entityimage&Id=f3baf772-9192-ed11-aacf-6045bd44fb6c&Timestamp=638091357298094244",

"createdon": "1/12/2023 3:55 PM",

"modifiedon": "1/12/2023 3:55 PM",

"emailaddress1": "someone_j@example.com",

"address1_city": "Renton",

"address1_telephone1": null,

"parentcustomerid": "dfbaf772-9192-ed11-aacf-6045bd44fb6c",

"parentcustomeridname": "Coho Winery (sample)",

"@search.parentcustomerid.logicalname": "account",

"telephone1": "555-0109"

},

{

"@search.score": 5.5241776,

"@search.highlights": {

"name": [

"{crmhit}Jim's{/crmhit} Accounting"

]

},

"@search.entityname": "account",

"@search.objectid": "9014d333-0e9a-ed11-aad0-002248cc94a7",

"@search.objecttypecode": 1,

"name": "Jim's Accounting",

"versionnumber": 1280040,

"statecode": [

"Active"

],

"statuscode": [

"Active"

],

"entityimage_url": null,

"createdon": "1/22/2023 4:35 AM",

"modifiedon": "1/22/2023 4:35 AM",

"emailaddress1": null,

"address1_city": null,

"accountnumber": null,

"primarycontactid": null,

"primarycontactidname": null,

"telephone1": null

}

],

"facets": {},

"totalrecordcount": 3

}

skip – This is another optional parameter of the type number. You can skip a certain number of records using this. The syntax is as below –

Power-Automate-Flow

top – This is an optional parameter of the type number. You can limit the records to a certain number. The syntax is as below –

Power Automate Flow

orderby – This is also an optional parameter that can be used to order the results by any particular fields in ascending or descending order. The order by field should be the fields that are available in all the entities in case you are searching through multiple entities. The syntax is as below –

Power Automate Flow

Conclusion

In this way, optional parameters can be used to limit the search as per our requirements.

Work smart with our assistance in automation!

Automating mundane Business Operations will save a lot time for newer tasks!
Our Inogic- Professional Services Division will help you wind up your codes, optimize them, and make operations easy. Write to us at crm@inogic.com right away and embrace the magic of Power Automate completely.