web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Anonymous user read ac...
Power Pages
Unanswered

Anonymous user read access to account entity

(0) ShareShare
ReportReport
Posted on by 73

We have a requirement to allow an anonymous user to read some Account data

I have created a read only entity permission for the Account entity. This has been given to the anonymous user web role

I have an account number. I want the anonymous user to be able to retrieve the account name for the account number.

 

I've been able to do something similar for an authenticated user using the current user as below (not quite the same as for an anonymous user)

 

<!-- Get organisation name for current user -->
{% assign account = entities.account[user.parentcustomerid.id] %}
{% assign organisationname = account.name %}

 

How do I do this for an anonymous user?

 

Thanks

Categories:
I have the same question (0)
  • Christian Leverenz Profile Picture
    1,214 on at

    Hi @paulinolan ,

    you have to pass in the accountid (if your user has it) as a paremeter to the page, so someting like https://myportal.powerappsportsls.com/myaccountpage/?accountid=12345678-1234-1234-1234-1234567890abc

    and within that page your liquid can obtain the accountid via 

    {% assign theid = request.params["accountid"] %}

    and then use that "theid" as the id for retrieving the accountifo.

     

    Ah, and when you pass in the accountnumer, you could do something like 

    {% assign theaccountnumber = request.params["accountnumber"] %}

    {% fetchxml anaccount %}

    <fetch count="1" no-lock="true">

    <entity name="account">

    <attribute name="accountid" />

    <attribute name="name" />

     

    <filter>

    <condition attribute="accountnumber" operator="eq" value="{{ theaccountnumber }}" />

    </filter>

    </entity>

    </fetch>

    {% endfetchxml  %}

    {%- assign myaccount = anaccount.results.entities[0] -%}

    {%- assign myaccountname = myaccount.name -%}

    (of course you should do some checking, whether an accountnumber was passed in and whether the fetch found something. But you get the idea 🙂)

     

    Does this help?

    Cheers,

      Christian

     

    PS the code was written in this editor and not syntax checked...

  • PN-28081327-0 Profile Picture
    73 on at

    Hi chleverenz

    Thank for the reply. Our scenario is slightly different. We have retrieved the id from a SQL Server table. We have a javascript function (that takes the id as a parameter) which will retrieve some data such as a name based on the id.

    I'm having as issue whereby how do I use the paramater passed into the function in the fetchxml, how do I assign it to a variable I can use in the fetchxml?

    e.g. The following displays blank in the console, what should the syntax be for the assign?


    var id = "7a3fab32-aa43-ec11-8c62-0022487f1e29" -- this would be the id from SQL Server table

    someFunction(id);


    function someFunction(account_id){

       

        {% assign accountid = account_id %}

        console.log('{{ accountid }}')


        some fetchxml using accountid

        -
        -
        -
    }

  • Christian Leverenz Profile Picture
    1,214 on at

    Hi @paulinolan ,

    the problem on this one is, that the javascript is executed on the client and the liquid is executed on the server.

     

    This is a little bit discussed in this: https://powerusers.microsoft.com/t5/Power-Apps-Portals/How-to-pass-javascript-variable-into-liquid-fetch-in-portal/m-p/1360438#M9896  thread.

     

    So, in principle you have to create that jsonpage which then retrieves accountinformations based on the id which is passed in there as a parameter. You will find the code and response on that in the 10th reply  (on the bottom of the first page) 🙂

    Does this fit your needs? 

    Have fun,

      Christian

  • Christian Leverenz Profile Picture
    1,214 on at

    Ah, just a remark. When the page is already called with that id, in my opinion you do not need to create a dedicated servicepage. The code from the first response should fit and vou could pass in the result of the fetch to a js- variable:

    <script>

    var myaccountname = "{{ myaccountname }}";

    </script>

    now, this js-variable is globally available in your script (may be you find a better place to render that piece of js 🙂 )

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard