Showing posts with label Sharepoint 2010. Show all posts
Showing posts with label Sharepoint 2010. Show all posts

Monday, June 13, 2011

How to use Sharepoint Cmdlets in powershell

To use the powershell commandlets in sharepoint 2010 one needs to add the ps snapin  Microsoft.SharePoint.PowerShell which can be done using the following command on windows powershell


Add-PSSnapin Microsoft.SharePoint.PowerShell.

Njoi 
~Abhishek

Wednesday, December 8, 2010

Getting logged on user details in ItemAdding event in SPItemEventReceiver

I am writing a sharepoint 2010 Custom List event receiver. I am able to get the events which are happening on the list items however there's no obvious way to get the logged on user's details in ItemAdding Event. 
This is the event which occurs before the Item is added. 
SPContext.Current is null for some reason and hence its kind of a dead end to go towards this path. 
A non obvious way to achieve this is by using the following code snippet. 


public override void ItemAdding(SPItemEventProperties properties)
{

      SPUser user =               properties.OpenWeb().AllUsers.GetByID(properties.CurrentUserId)
}

~Abhishek

Wednesday, December 1, 2010

Problem Accessing Dynamics CRM 2011 Beta services from BCS in Sharepoint 2010

Dynamics 2011 Beta exposes a new oData based service which can be used to pull data out from the system. I am working on BCS for Sharepoint 2010 for a simple demo and i decided to use this service to pull data from CRM 2011 beta system.
After setting the reference i tried to use the DataContext object to pull data out and got an exception which said
"Request version '1.0' is too low for the response. The lowest supported version is '2.0'."
On digging a little deep i realized that some header mismatch is happening between the oData service and my client.
MSDN social says that in order to change this header from 1.0 to 2.0 i need to target my assemblies to compile and run against .NET 4.0. To my utter surprise Sharepoint 2010 runtime can't load the assemblies which are targeted for 4.0 and hence i had to fall back on using the old way of accessing data from CRM which is using CRM data service. That's bad news as this means i will have to write lot of code which i could have done without.
The good thing though is that i will learn the old way of accessing data from the system. Will try to post some code samples.....

Regards, Abhishek