We have a requirement where the account lookup (on a form within a webpage) should be pre-filled with an account of the contact (or parentaccount) where a specific field (xxx_IsAgency) is set to YES.
For this purpose, the organization tree must be iterated recursively from the contact upwards and a stop must be made at the point where "xxx_IsAgency" = Yes can be found. This organization must then be stored in the account lookup field.
Any suggestions (maybe an example) how to properly define the WEB API for this request?
Thank you very much!
Hi, I don't think you need to run iterate through all the account records.
You need a read operation "accounts where primarycontact = user.id and xxx_isAgency = yes"
this might bring multiple results, so you might need to define a sorting criteria, and simply pick the first
If it is multi-level hieratical you may need to look at 'above' or 'under' type conditions - not sure how this will go with the Web Api https://docs.microsoft.com/en-us/power-apps/developer/data-platform/query-hierarchical-data
yes it is most likely multi-level hieratical. Do you know how to properly write it if the query should give me the first hieratical organisation that has the field set to yes?
Contact => Org 1 (field = no) ==> Org 2 (field = no) ==> Org 3 (field = Yes)
Not sure if it will work with the Portal Web API, nor exactly what your query needs to be but the general 'Above' would be something like
(use XrmToolBox and the FetchXML builder, you can then see what the oData equivalent is of the FetchXML)
If the Portal Web API does not support it you can always revert to the old way of setting up a portal page with a liquid template making a FetchXML query and then calling that page via Ajax.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.
Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.