0
   if (user.get_isSiteAdmin()) 
    {
    document.cookie = "licence=yes";
    }

I am using user.get_isSiteAdmin() but its always giving value false I can not give permission to site site collection

Site Collection - Full Control 

in AppMenifest.xml file

is there any other way to get site administrator ?

Asjad Ali
  • 25
  • 7

1 Answers1

0

@user11869887,

Just have a test this JSOM function on my SPO environment, it works fine here. enter image description here

you may need to explicitly initialize the object/properties, or it will always return false as the related property is null.

BR

Baker_Kong
  • 1,739
  • 1
  • 4
  • 9
  • I have tried this but its not working in my case here is code which I have written its still giving value false of get_isSiteAdmin var user = web.get_currentUser(); this.clientContext.load(user); this.clientContext.executeQueryAsync(() => { if (user.get_isSiteAdmin()) { document.cookie = "licence=yes"; } } – Asjad Ali Sep 07 '20 at 08:26
  • How about "_spPageContextInfo.isSiteAdmin"? https://www.codeproject.com/Articles/1109529/spPageContextInfo-in-SharePoint – Baker_Kong Sep 07 '20 at 09:34
  • **These methods works fine when I give permission full-control to site collection in AppMenifest.xml file. Otherwise they are giving value false of isSiteAdmin and I can't give full-control permission to site collection** – Asjad Ali Sep 08 '20 at 10:08