Pages

Thursday, October 31, 2013

Finding SharePoint Item Level Permissions in ECMAScript


In EMAScript, to find out item level permissions in a list/library we don’t have respective
object in CurrentItem which states with Permission Name. Generally if we do the same in
 Server Object Model it returns Permission Names in string format. This ease our task but
in ECMAScript it returns in nvarchar format.

For Example, to know whether item has Read Permission, below is the snippet code.

if (ctx.CurrentItem.PermMask == "0xb008431061") { //This value is for Read Permission
}
else {
}

Wednesday, October 30, 2013

Solution for Nintex forms 2013 not working with Custom Master Page in SharePoint 2013


 Problem:-
I am using custom master page and installed the Nintex forms 2013 in my SharePoint 2013 environment.
When I click on any New Item which contains the Nintex form getting below error.

The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.

Solution
The resolution steps are

Step 1:- Find the below lines from header:

<SharePoint:AjaxDelta id="DeltaSPWebPartManager" runat="server">
<WebPartPages:SPWebPartManager runat="server"/>
</SharePoint:AjaxDelta>

Step 2:- Cut it out...Go to the body part... find div with the id "s4-workspace" and paste the code before this div like this:
<SharePoint:AjaxDelta id="DeltaSPWebPartManager" runat="server">
<WebPartPages:SPWebPartManager runat="server"/>
</SharePoint:AjaxDelta>
<div id="s4-workspace">
[...]
 

Alternative for Connectable Webparts [Filter SharePoint list with Partial Postback to page]


Problem:-
The other day, I wanted to filter a list view web part, triggered from some action in the same page.
Every time I do action, I wanted to automatically filter the sharepoint list with that value, without
doing a full postback/refreshing the page.

Solution
Generally as SharePoint developer will get an idea to develop a connectable webparts, but this is
difficult and takes time. The alternative is from SharePoint 2013, we have a new page added in
layouts folder inplview.aspx. This generates the "inplviewhash" tag when we do filtering/sorting and
mainly it appends with "#" in url. As we know when we have # url, the page doesn’t gets reload[postback].

For Example:- If we have two webparts in the Page containing one action performed and second
showing respective filtered data. The approach is when we do action in the above webpart through
javascript frame below way of url.

Function createFilterURL() {
var filterstring += //Frame query string which contains the formatted of filterfield1,filtervalue1 [if multiple values filterfields1,filtervalues1].
var wpqschema = ctx.View;
var querystring +=  '#InplviewHash' + wpqschema.slice(1, -1).toLowerCase() + '=' + filterstring ;
window.location.hash = querystring;
}

Friday, October 18, 2013

Configure Audit Settings in SP 2013 Programatically

As you may get a requirement to configure Audit Settings for a Site Collection/ Web/List of SharePoint through Programatically. Listed out below the respective API and Methods which help for better understanding.

  • Regarding setting up storage location to save audit entries. By default the audit logs in sharepoint will save in the sharepoint database. If you want to store in particular document library, we need to below way. 
using Microsoft.Office.RecordsManagement.Reporting;
{
....
AuditLogTrimmingReportCallout.SetAuditReportStorageLocation(site, "{Documents Library Name}");
....
}
        For more detailed info please see
http://msdn.microsoft.com/en-us/library/microsoft.office.recordsmanagement.reporting.auditlogtrimmingreportcallout.setauditreportstoragelocation.aspx

  •   Regarding Setting up the Retention period, this is a straight forward where we have the respective property.       

      site.TrimAuditLog = true;
      site.AuditLogTrimmingRetention = 30;

  •  Be default the retention period will be 60 days in SharePoint.