Using filtered view in Callout and Plugin

For using filtered view within the callout/plugin I used the following code

SqlConnection connection = new SqlConnection(“Data Source=dsname;Initial Catalog=dbname ;Integrated Security=SSPI;”);

string sqlQuery = @”select * from filteredOpportunity”;

SqlCommand cmd = new SqlCommand(sqlQuery, connection);

connection.Open();

//// your logic here

connection.Close();

 

But this code wasn’t returning any results .It was because callout/plugin run under the context of NT Authority\Network Service.

So we need to use impersonation in this case, for this we can use the following code

 

SqlConnection connection = new SqlConnection(Data Source=dsname;Initial Catalog=dbname ;Integrated Security=SSPI; Pooling=false”);

string sqlQuery = @” SETUSER ‘domainname\administrator’ select * from filteredOpportunity;

SqlCommand cmd = new SqlCommand(sqlQuery, connection);

//// your logic here

connection.Open();

 

SETUSER – To impersonate the admin who has access to the filtered views. More about SETUSER

http://msdn.microsoft.com/en-us/library/ms186297.aspx

 

Pooling-False This is important otherwise we will get the below error

 

The connection has been dropped because the principal that opened it subsequently assumed a new security context, and then tried to reset the connection under its impersonated security context.

Check this wonderful post as well

http://blogs.msdn.com/b/crm/archive/2007/05/21/writing-crm-callouts-with-filtered-views.aspx

 

Bye

 

Could not load XSL file. The system cannot find the file specified. (Exception from HRESULT: 0x80070002) Content By Query Web Part

We recieve this error while trying to edit ContentByQueryWebPart.

The reason for this error is because the publishing features are not enabled for the site.

So we need to enable the publishing features.

For this first activate Office Sharepoint Server Publishing Infrastructure feature found at

Site Collection Administration – Site Collection Features.

Than enable Office Sharepoint Server Publishing feature at Site Administration- Site features

Bye

Preventing your system from getting auto locked

Within most of the organization, there is a default setting that after a few minutes have escaped, the system gets locked itself, if system is left unattended. Well to prevent this i have written a small utility (windows application) which periodically sends user input to the system, making it to believe that some mouse movement has been made and thus stopping the system from getting locked.

Here we would be calling SendInput function within user32.dll

The SendInput function synthesizes keystrokes, mouse motions, and button clicks and that is what we need.

http://msdn.microsoft.com/en-us/library/ms646310.aspx

This is useful in case we are giving presentation or else reading some documents …

Following is the code for the same

1) Create a new windows application in C#

2) Add a button named btn_Unlock to it and a timer control named timer1.

3) Set enabled to false and interval to 120000 for timer control.

4) Put the following code to your form class


public partial class frmKU : Form

{

public
frmKU()

{

InitializeComponent();

}

[DllImport(“User32.dll”, SetLastError = true)]

public static extern int SendInput(int
nInputs, ref INPUT
pInputs, int cbSize);

public struct INPUT

{

public
int type;

public
MOUSEINPUT mi;

}

public struct MOUSEINPUT

{

public
int dx;

public
int dy;

public
int mouseData;

public
int dwFlags;

public
int time;

public
int dwExtraInfo;

}

// Call the
API

int
resSendInput;

private
void btnUnlock_Click(object
sender, EventArgs e)

{

timer1.Enabled = true;

INPUT
input = new INPUT();

resSendInput = SendInput(5, ref input, Marshal.SizeOf(input));

}

private
void timer1_Tick(object
sender, EventArgs e)

{

INPUT
input = new INPUT();

resSendInput = SendInput(5, ref input, Marshal.SizeOf(input));

}

}

 

Bye …

Passed Exam MB2-634: CRM 4.0 Extending Microsoft Dynamics

Today I cleared the extension exam for Microsoft Dynamics CRM 4.0 with score of 82.

For version 3.0 the number of questions were 40 and passing score was 80.

This time around for version 4.0 there were 50 questions but how much is the passing score it wasn’t mentioned anywhere.

For preparation i used the the course material 8969 and CRM as a Rapid Development Platform book.

CRM as a Rapid Development Platform – I found this book really very useful..

Although from exam point of view the course material 8969 is more than enough !!!

Bye ..

Retrieving the COM class factory for component with CLSID {3D42CCB1-4665-4620-92A3-478F47389230} failed due to the following error: 8007042d.

I got this error while trying to perform a backup within backup and restore inside operations of Central Administration site.

I checked services on server within operations and it was showing that all the services had started, but on checking at services.msc i found out that the following service hadn’t started

Office SharePoint Server Search, after starting this service, the error got resolved.

Find more information over here

http://social.technet.microsoft.com/forums/en-US/sharepointgeneral/thread/dc1db06b-ac78-4547-b28d-a0d1efab3b80

Bye

Customizing Export to spreadsheet in Survery or Adding columns for export to excel in Survey (Sharepoint)

We wanted to have created column value in the excel sheet for our survey responses. We modified the existing view to include the created column and then selected the option of Export to SpreadSheet. But it was not including the created column.

 

So the solution for this was to

 

Select All Responses View than

Site Actions – Edit Page – Modify the shared web part – Edit the current view – Than selecting the created column and copying the url of that page

 

http://servername:12345/_layouts/viewedit.aspx?List=%7B545889CC%2D1BE0%2D463D%2DBAA2%2D6DBEC360BA68%7D&View=%7B107DCB6B%2D83D8%2D439C%2D8996%2DF1B7782C8062%7D&Source=http%3A%2F%2Fd%2D1246%3A12345%2FLists%2FDemoSurvey%2FAllItems%2Easpx%3FPageView%3DShared

 

Get the id of the view

%7B107DCB6B%2D83D8%2D439C%2D8996%2DF1B7782C8062%7D

Which is

107DCB6B-83D8-439C-8996-F1B7782C8062

 

%7B is equal to {

%7D is equal to }

%2D is equal to –

 

Go back to survey, click on Action – Export to spreadsheet – Save the query to your machine and make the following changes in the query

 

WEB1

http://d-1246:12345/_vti_bin/owssvr.dll?

XMLDATA=1

&List={545889CC-1BE0-463D-BAA2-6DBEC360BA68}

&View={ED178AE0-E856-47FD-AB02-E1566F30E400}

&RowLimit=0&RootFolder=%2fLists%2fDemoSurvey

Selection={545889CC-1BE0-463D-BAA2-6DBEC360BA68}-{ED178AE0-E856-47FD-AB02-E1566F30E400}

EditWebPage=

Formatting=None

PreFormattedTextToColumns=True

ConsecutiveDelimitersAsOne=True

SingleBlockTextImport=False

DisableDateRecognition=False

DisableRedirections=False

SharePointApplication=http://d-1246:12345/_vti_bin

SharePointListView={ED178AE0-E856-47FD-AB02-E1566F30E400}

SharePointListName={545889CC-1BE0-463D-BAA2-6DBEC360BA68}

RootFolder=/Lists/DemoSurvey

 

 

Replace the above value with the value of your view i.e. 107DCB6B-83D8-439C-8996-F1B7782C8062.

 

Now when you will open this query it will show all the columns specified by you in the view.

 

Another option could be to use Data View web part for it and adding the required column to it through sharepoint designer. And than right clicking on it and selecting Export to Microsoft Excel from the context menu of the IE.

 

Bye