I was working in the SharePoint 2013 OOTB “Task List” and developed a custom visual web-part for the “Newform.aspx” and “EditForm.aspx” , having all the control as present in the OOTB forms. (You must be thinking that why I developed custom forms, however this question is out-of-context for this blog). Since I was the site collection administrator, I never faced any issues while adding new items or editing the existing ones.

However, users who are having the “Full Control” or “Contribute” permissions at the task list level , reported that they are facing the following issue which says that they do not have permissions to add new items. On the first thought,  it seemed to me a permission issue but I found that if I click on new item from my machine, they were able to open the form from their machines and can add new items in the task list ….Strange enough !!

Error message – “You don’t have Add and Customize Pages permissions required to perform this action”

Web part error

Web part error





Solution 1:-

1. Add a new permission level which only includes “Add and Customize Pages” permission, and then create a new SharePoint group with this permission level.
2. Add the users into the SharePoint group and these users will get the “Add and Customize Pages” permission from the site level (site permission).

Solution 2:-

If above solution does not work in your system, then give “Full Control” permission to the users at the Site Level.

Hope this blog helps many 🙂

Important points to know about Site Columns and Content Types in SharePoint 2013

In one of my recent projects of SharePoint Online (Office 365), I need to create the site architecture starting with creation of Site Columns and Site Content Types. To give you the glimpse of the project, it involved roll-up and roll-down of data from 300 sub-sites under the root site collection. So, I decided to use Content Search web-part which allows to roll-up the data and by modifying the queries, we can roll-down the data too.

What I learnt –

  1. Use OOTB site columns as much as possible, do not create your new site columns if already provided by SharePoint. However, if OOTB columns doesn’t suits your requirement, then you can create new custom column (For E.g. – OOTB “Due Date” columns is of Date type, so if you wish Date and Time type column then you cannot use this OOTB column)
  2.  Always create a separate group for your site columns and content types.This will help you to filter the columns and content types.
  3. Many times, we make columns as Hidden for one list/library and then try to add the same columns in other list/library which we find is not available. So, before adding a site column in any list/library or any content type, make sure that the column is not hidden at top level.
  4. After migration or after creating a site template, your site is not getting created (assuming your site having workflow also), then change your .wsp file to .cab file and check the XML files. Try to delete the duplicate entries of site columns and content types which are created twice.

Check Existence of User in SharePoint Group using JSOM

While working with SharePoint objects it’s required to check whether user is present in which SharePoint group.Hence, the below script comes in handy to check existence of user in SharePoint group using JSOM.

ExecuteOrDelayUntilScriptLoaded(IsUserExists, “sp.js”);
var spfGroup;
var spfUsers;
var context;
var spfGroupCollection;
var spfUser;

function IsUserExists() {
context = SP.ClientContext.get_current();
spfGroupCollection = context.get_web().get_siteGroups();
spfUser = context.get_web().get_currentUser();
spfGroup = spfGroupCollection.getById(101);
spfGroup = spfGroupCollection.getByName(“SPF Owners”);
context.executeQueryAsync(Function.createDelegate(this, this.OnGetGroupSuccess), Function.createDelegate(this, OnFailure));


function OnGetGroupSuccess() {
spfUsers = spfGroup.get_spfUsers();
context.executeQueryAsync(Function.createDelegate(this, this.OnGetuserSuccess), Function.createDelegate(this, OnFailure));

function OnGetuserSuccess() {
var userEnumerator = spfUsers.getEnumerator();
while (userEnumerator.moveNext()) {
var spfUser = userEnumerator.get_current();
if (spfUser.get_id() == spfUser.get_id()) {
alert(“User Exists”);
} else {


function OnFailure(sender, args) {
alert(“Failed to execute IsCurrentUserMemberOfGroup method”);

Hope this blog helps 🙂

Install and Uninstall SharePoint Solutions via Powershell

This blog will outline the cmdlets to uninstall and install SharePoint solutions via Powershell.

For installing the solution, first we need to add the solution to the farm:-

Add-SPSolution -LiteralPath “Path where the solution is kept(D:\sharepoint.wsp)”

Final step will be to deploy the solution by using below command :

Install-SPSolution -Identity “Name of the solution(sharepoint.wsp)” -GACDeployment

In case we want to deploy the solution to different versions of SharePoint we have to use Compatibility level parameter.

Install-SPSolution -Identity “Name of the solution(sharepoint.wsp)” -GACDeployment -CompatibilityLevel “14,15”

For uninstallation,

First we need to uninstall the solution which will remove all the existing association from the farm.

Uninstall-SPSolution -Identity “Name of the solution(sharepoint.wsp)”

Post uninstalling, we need to complete the process by removing the solution from the farm.

Remove-SPSolution -Identity “Name of the solution(sharepoint.wsp)”

Hope this blog helps 🙂

Using Merge-SPLogFile – SharePoint Correlation ID

When you are hit with a error/exception in SharePoint, you get notified to use a Correlation ID to check for details in the trace logs (ULS logs).

The Merge-SPLogFile cmdlet returns records from Unified Logging Service (ULS) trace log files on each farm server that match the criteria, and writes the results to a new log file on the local computer. If no results are returned, a warning is written to the Windows PowerShell console window.

Merge-SPLogFile -Path [FILE PATH] -Correlation [CORRELATION ID]


Merge-SPlogfile –Path C:\log.txt –Correlation 29b5c483-c48b-4ef2-b4b3-f5e29f635d31

This will generate a file named “log.txt” at location C:\. This creates a much smaller output file to search through and all of the entries in the log file are related to the particular Correlation ID only.

Get Query String In JavaScript

It’s a very common task to Get Query String in JavaScript. I use this JavaScript function in every other project and every time.

function getParameterByName(name) {
 name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
 results = regex.exec(;
 return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
var strValue = getParameterByName('Value');

SharePoint 2010 User Profile Synchronization and AD Account Deletion

Recently I’ve been asked about what happens to accounts deleted from Active Directory with respect to SharePoint 2010 User Profiles, and the User Profile Synchronization service instance.

Let’s take a simple scenario of an AD(SharePoint Users) which contains 60 users, this will be used by our SharePoint Synchronization Connection. Once we’ve run an Incremental Synchronization, all is good we see all of these users in UPA Management and also within Manage User Profiles (there are 61 because there is also a profile for the Administrator account).

So far so good, nothing out of the ordinary. We now go ahead and delete all the test user accounts in AD (let’s say few users) and run another Incremental Synchronization.

During the DS_DELTAIMPORT phase of synchronization, the deleted accounts are removed from the metaverse (Sync DB).

What will happen here is that during the first incremental synchronization after the accounts are deleted from AD, the user profiles will be marked for deletion in the Profile database.

This is important. It is also a common misconception that a full synchronization is required. The profiles still exist in the Profile DB and are a simply marked for deletion. This aside from being confusing in the UI, can lead to problems in custom code that does something based upon the total number of profiles. It doesn’t matter how many times we run a sync, the total profiles will remain the same.

In order to actually delete the profiles, we must run the My Site Cleanup Timer job. This job will delete the profiles marked for deletion and therefore once complete make the count tally with the number of usable profiles. The My Site Cleanup Job is scheduled to run hourly by default (and I strongly recommend you do not change this, for once, entirely reasonable default). An important point to note is that this job requires a My Site Host to be configured on the UPA, even if you are not using My Sites. If there is no My Site Host configured the job will fail and the profiles marked for deletion will never be deleted.

Hope this helps 🙂