View stack trace for visual studio sharepoint deployment by enable diagnostics logging for SharePoint projects

I have a problem in visual studio SharePoint projects deployment that when an error occurred there is no stack trace enabled that i can see the details of the error like that

VS Deployment Exception

So i found a solution to enable stack trace for SharePoint projects in visual studio by adding a registry key to enable diagnostics logging for SharePoint projects

  1. Open registry  editor  by open start up menu – > type run -> type regedit then click ok
  2. Create a DWORD key type , the name is “EnableDiagnostics” and value “00000001” under HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\SharePointTools      “the “10.0″ folder for visual studio 2010 and you can do the same in your visual studio version

enable diagnostics logging for SharePoint projects

  1. Restart the operating system
  2. Now i can see the details of deployment in the visual studio output window as image below and in which step it fails.

Visual Studio SharePoint Deployment Exception Stack Trace

Hope it will help.

Visual studio wsp deployment Error occurred in deployment step ‘Add Solution’: Value cannot be null

Sometimes when you try to deploy your SharePoint solution from visual studio an error occurred

visual studio wsp deployment Error occurred in deployment step ‘Add Solution’: Value cannot be null

The error comes because you opened “Elements.xml” in visual studio IDE when you deploy the solution ! it fails when the “FindConflicts()” method invoked during add solution step in visual studio deployment.

Two solutions to solve that :

  1. Simply close any “Elements.xml” file opened in visual studio IDE then deploy it will success :D
  2. Change deployment conflict resolution for your module from Automatic “the default value” to None – image below

deployment conflict resolution

That’s it !  :)

Set HTML attrbuites from SharePoint content type fields in page layouts

The Problem / Example : Need to put the “alt” attribute in the HTML “img” element from a content type field “Title” in a custom page layout and the content type fields represented as a SharePoint controls like that

SharePoint Field Value Control

You can do that simply by CSS/ JQuery :

1-Hide the SharePoint control that represent the field value using CSS and give the span container an ID “Ex: spanTitle” :

Hide SharePoint Field Value

2-Write the HTML “img” element with attribute “alt” empty and give it an id “Ex:exampleImage”  :

HTML img element3-Write these lines of JQuery that will fetch the value from the hidden span and put it to the “alt” attrbuite in the “img” element :
Fetch SharePoint Control Value And pass it to HTML attrbuite

Thanks !

Bulk delete SharePoint workflow tasks with associated history items using PowerShell

I Written this script to bulk delete old completed workflow tasks with related history items by specify the date that script will stop delete until it.

The script were treated to deal with a huge number of data.

Click here to download The script

Click here to download from TechNet Gallery


1. Read the Instructions in the top of the file to set the script parameters

Bulk delete SharePoint workflow tasks with related history

Script Instructions part

Continue reading

Table of list template IDs and SPListTemplateType enumenration members in SharePoint

Table of list template IDs

Programming over SharePoint XML files needs List Template ID in many cases “List definitions xml , site deifnations xml , event receivers xml  ,etc..) , here is a table for list template IDs

Continue reading

Create SharePoint event receiver for sepcifc list

When you create a new SharePoint event receiver from Visual Studio the Visual Studio asks you “What item should be the event source” – ” see image below”

For example if you choose the list template “Survey” that means your event receiver will applied in all lists from the type survey , but in the real work you need to specify a list instance which the event receiver will apply to it .

Continue reading

Understanding group by in LINQ by example

We will describe it by a full example “the full code in the end of the post for copy”

In this example we will create 2 classes , the “Task” class which has the task properties and the “TasksGroupedItem” which has 3 properties:

-Task day :  it will contain the task day that we will group by

-List<Task>  : it will contain list of tasks per Task Day

Then we will create a function that takes List<Task> and return List<TasksGroupedItem> , here is the code

Continue reading