Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

PowerApps Portal Lookup Field Views

  • 1.  PowerApps Portal Lookup Field Views

    TOP CONTRIBUTOR
    Posted Jan 28, 2021 04:20 PM
    Edited by Andy Arndt Jan 28, 2021 04:25 PM
    I have a PowerApps portal that I'm doing a little customization on. I have a lookup field on an entity form and I have two views specified for it in design view of the form. I want to programatically set the view on form load based on some field values on the form and restrict it so the user can't change the view. I think I've done this in the CRM UI with code like this: FormContext.getControl("lookupfieldname").setDefaultView("GUID");

    Does anyone know how to do this in a PowerApps Portal?

    I've seen some code to filter related records on lookups using request.params, but I simply want to set the view, not do any additional filtering.

    #PowerApps

    ------------------------------
    Andy Arndt
    Minitab, Inc.
    State College PA
    ------------------------------


  • 2.  RE: PowerApps Portal Lookup Field Views

    TOP CONTRIBUTOR
    Posted Feb 08, 2021 08:14 AM
    I ended up working with Microsoft support on this. I was told there is no way to dynamically set the view for a lookup control on a portal form. It's unfortunate because it's literally one line of code in the CRM client API. They said I may be able to accomplish filtering with fetchxml. I then investigated more on my own and found the following.

    Render lookup as dropdown on portal page and apply xml filtering:

    https://www.dancingwithcrm.com/custom-lookup-filtering-powerapps-portal/

    The above site says to make a web template, but doesn't describe the other parts of the process. Those are described here:

    https://www.inogic.com/blog/2020/11/use-of-json-type-web-templates-in-powerapps-portals/

    Web Template, Page Template, Web Page. The Web Template has a mime type of application/json, the Page Template uses the Web Template, and the Web Page uses the Page Template. Then, the web page can be accessed with its input parameter like this: https://portalurl.powerappsportals.com/webpage?parameter=value

    Render lookup as dropdown is a checkbox in the entity form metadata.

    1. Entity form has metadata to render the lookup as a dropdown
    2. The entity form also can contain custom javascript that calls the web page
    3. The web page is based on a page template that is based on a web template
    4. The web template has the fetchxml and returns json (mime type specified on web template)

    The calling function in the custom JavaScript then parses the JSON and populates the value and innerText for the items in the drop down.

    ------------------------------
    Andy Arndt
    Minitab, Inc.
    State College PA
    ------------------------------



If you've found this thread useful, dive deeper into User Group community content by role