Skip to main content

Search

Anonymous Access

Comments

6 comments

  • AndrewBerezovskyy2

    Hello Senad Omicevic

     

    This happens because anonymous users are not able to do CSOM calls from js code. You can easily overcome this.

    Please read chapter Enabling CSOM for Anonymous Users from this article

    https://blogs.msdn.microsoft.com/kaevans/2013/10/24/what-every-developer-needs-to-know-about-sharepoint-apps-csom-and-anonymous-publishing-sites/

     

    Best Regards

    Andrew Berezovskyy

    0
  • Senad

    Hello Andrew,

     

    great article, thank you.

     

    I have succeed to open now the list with the anonymous user. Can you please tell me how to overcome this expression:

     

    Error occured on evaluating expression "=[[@User.Title]] == "NormalUserName" ? parseInt([[@Web.GetFirstValueForQuery('/mysite/Lists/MyList', '<View><Query><OrderBy><FieldRef Name="Field2" Ascending="False" /></OrderBy></Query><RowLimit>1</RowLimit></View>', 'Field1)]])+1 : """
    could not load list

     

    why does it try to load the list because the expression is False (Anonymous user) and it should return just "".

    Can I improve the if statement to check if its a anonymous user as well? 

    0
  • Senad

    I get as well such a error: 

    Error: The Method “GetItems” of the type “List” with id “{Lists’s Guid}” is blocked by the administrator on the server

    I found a PowerShell script which can solve this problem in this article:

     

    Error: The Method “GetItems” of the type “List” with id “{Lists’s Guid}” is blocked by the administrator on the server |… 

     

    has anyone maybe tried this? Can this method cause any problems in the background or is it just like it says that the anonymous can use the "GetItems" on lists where he has permissions?

    0
  • AndrewBerezovskyy2

    Hello Senad Omicevic

     

    Thank you for helpful link. I think you can use that approach.

     

    Kind Regards
    Andrew Berezovskyy

    0
  • AndrewBerezovskyy2

    Hello Senad Omicevic

     

    Why does it try to load the list

    At first all placeholders into expression will be processed and replaced . In your case , at first [[@Web.GetFirstValueForQuery..]] placeholder will be processed and only after that will be applied  ==  operator .

     

    In the case of request page as anonymous user next expression [[@User.Title]] will return null.

    When you use GetFirstValueForQuery and anonymous user has not any permissions on your /mysite/Lists/MyList list then GetFirstValueForQuery will throw error.

     

    In this case better approach is using  Set Form Field Value action. For your field ,on wich you had expression (GetFirstValueForQuery), you must add two  Set Form Field Value actions. First action will be executed for not anonymous users and second expression will be executed for anonymous users. 

    In first action you can use next condition (Type:Function code) for detecting not anonymous users: 

    { var IsNotAnonymousUser = [[@User.Title]];return IsNotAnonymousUser; } .

    In second action you can use next condition (Type:Function code) for detecting anonymous users: 

    { var IsNotAnonymousUser = [[@User.Title]];return !IsNotAnonymousUser; }

     

    Hope this will help you =)

     

    Kind Regards
    Andrew Berezovskyy

    0
  • Senad

    Hi Andrew,

     

    Thank you for your explanation.

    I have tried your solution and it's working perfect!

     

    This is a great help, thank you.

    0

Please sign in to leave a comment.