Does anyone ever check if user is site collection admin in SharePoint 2010 in ECMA script? I googled around and can’t find any working solutions. It’s very weird that they make it so hard to do the check in SharePoint 2010.
Thanks,
Perry
Hi Manjunatha,
Is there a way to get it by group title.
if i move my solution from one server to another i can’t redeploy my solution by chaning the id on every environment.
Thanks,
Bharath P N
Hi,Â
group=groupcollection.getById(7);
Where ‘7’ is not a Site collection Admin group ID,I just passed one group id to get some group,that’s it.
Thanks,
ManjuÂ
Hi Manjunatha,
Thanks very much for your reply and the sample code.
In your code, the line group=groupcollection.getById(7); Does that mean the group id of the Site Collection Admin group is and always be “7”?
Thanks again,
Perry
Hi,
Add the content editor webpart ,edit the webpart and type the following code.
<script language=”ecmascript” type=”text/ecmascript”>
var group;
function Groupowner(){
var clientcontext=new SP.ClientContext();
var groupcollection=ClientContext.get_web().get_siteGroups();
group=groupcollection.getById(7);
clientContext.load(group);
clientContext.executeQueryAsync(Function.createDelegate(this,this.OnQuerySucceeded),Function.createDelegate(this,this.onQueryFailed));
}
function onQuerySucceeded()
{
alert(group.get_title()+”groupowner- ” +group.get_ownerTitle());
}
function OnQueryFailed(sender, args)
{
alert(‘Requested failed’+args.get-message()+’\n’+args.get_stackTrace());
}
<input id=”btnGetGroupOwner” onclick=”getGroupOwner()” type=”button” value=”Get Group Owner” />
I hope it’ll help you
Because I need to do that on a web page. It’s a programming task but not an admin task.Â