Hi All,
I have custom ribbon button, want to enble/disable this button based on the list permissions could you please help me on this below code which i tried
<?xmlversion="1.0"encoding="utf-8"?>
<Elementsxmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="COB.SharePoint.Ribbon.CustomTab"
Location="CommandUI.Ribbon"
RegistrationType="List"
RegistrationId="101">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinitionLocation="Ribbon.Tabs._children">
<TabId="COB.SharePoint.Ribbon.CustomTab"
Title="My Custom Tab"
Description="Groups and controls will go in here"
Sequence="550">
<ScalingId="COB.SharePoint.Ribbon.CustomTab.Scaling">
<MaxSizeId="COB.SharePoint.Ribbon.CustomTab.valigroup.MaxSize"
GroupId="COB.SharePoint.Ribbon.CustomTab.valigroup"
Size="OneLarge"/>
<ScaleId="COB.SharePoint.Ribbon.CustomTab.valigroup.Scaling.CustomTabScaling"
GroupId="COB.SharePoint.Ribbon.CustomTab.valigroup"
Size="OneLarge" />
</Scaling>
<GroupsId="COB.SharePoint.Ribbon.CustomTab.Groups">
<Group
Id="COB.SharePoint.Ribbon.CustomTab.valigroup"
Description="This is a Physical Object Administration group!"
Title="xyz + abc"
Sequence="10"
Template="Ribbon.Templates.OneLargeExample1">
<ControlsId="COB.SharePoint.Ribbon.CustomTab.valigroup.Controls">
<Button
Id="COB.SharePoint.Ribbon.CustomTab.valigroup.vali"
Command="COB.Command.vali"
Sequence="40"
ToolTipTitle="Click to prompt hellow world"
ToolTipDescription="Once you click this button you will get Admin Dialog box"
Alt="ABC creating"
Description="CreatingABC"
Image32by32="/_layouts/IMAGES/ABC.GIF"
LabelText="Sayyed"
TemplateAlias="cust4"/>
</Controls>
</Group>
</Groups>
</Tab>
</CommandUIDefinition>
<CommandUIDefinitionLocation="Ribbon.Templates._children">
<GroupTemplateId="Ribbon.Templates.OneLargeExample1">
<LayoutTitle="OneLarge"LayoutTitle="OneLarge">
<SectionAlignment="Top"Type="OneRow">
<Row>
<ControlRefDisplayMode="Large"TemplateAlias="cust4" />
</Row>
</Section>
</Layout>
</GroupTemplate>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="COB.Command.vali"
CommandAction="javascript: alert('Its Working man')"
EnabledScript="javascript:
var Test;
var _currentUser;
var _theList;
function checkifUserHasEditPermissions()
{
Test=false;
context = new SP.ClientContext.get_current();
web = context.get_web();
this._currentUser = web.get_currentUser();
this._theList = web.get_lists().getByTitle('Shared Documents');
context.load(this._currentUser);
context.load(web,'EffectiveBasePermissions');
context.load(this._theList, 'EffectiveBasePermissions')
context.executeQueryAsync(Function.createDelegate(this, this.onPermissionsSuccessMethod), Function.createDelegate(this, this.onPermissionsFailureMethod));
}
function onPermissionsSuccessMethod(sender, args)
{
if (this._theList.get_effectiveBasePermissions().has(SP.PermissionKind.editListItems))
{
alert('User Can Edit the list.');
Test=true;
}
else
{
alert('User Can NOT Edit the list.');
Test=false;
}
return Test;
RefreshCommandUI();
}
function onPermissionsFailureMethod()
{
alert( 'user failed');
Test=false;
return Test;
}
checkifUserHasEditPermissions();"
/>
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
i am able to getting alert but not able to returning bool value(in my case "test" )here
Thanks in Advance
Esubvali Sayyed