Friday, June 15, 2012

Sharepoint EventCache and EventLog tables are too big

When the Sharepoint database is out of control !


A few days ago I noticed that the database for my WebApplication Sharepoint was overgrown. On opening the database I noticed that 90% of space was concentrated in just two tables: EventCache and EventLog.

To save space, at least for the EventCache table, I saw that you must set the throttling Changelog; to do this select from Central Admin WebApplication -> General Settings -> Resource Throttling, and set the Change Log to a low number (eg . 5 days).

Once this is done run the job called Change Log which is responsible for deleting records from the table EventCache (despite the name ...).

Once the job have finished, if you are not satisfied of the result or the disk space occupied is mainly assigned to the SQL log file (the file. Ldf), then you can do this:

1. Open the SQL managment console.
2. Select the database of the WebApplication.
2. Set the database recovery mode to Simple.
3. Run the Shrink Database.
4. Reset to Full recovery mode.

For the implications regarding the Recovery Mode SQL I recommend you read it here

Warning: Most of the time is often a program that update continuously items in the Sharepoint list, check if there are some custom Job Timer, Service or other programs.

Friday, June 1, 2012

Report Builder - List does not exist - 0x82000006

Today I encoutered a strange error while developing a Sharepoint list report with Report Builder.

List does not exist.
The page you selected contains a list that does not exist. It may have been deleted by another user.
0x82000006 (Microsoft SQL Server Report Builder)


This error happens when you design a new dataset, select your list and click Run Query.
After some troubleshooting I found the solution:
Into the Query Designer, after you have selected the Fields, click Edit as Text then in the command type select Text then re-click Edit as Text, to return to the graphic designer. Finally click Run Query

Monday, March 26, 2012

<nativehr>0x80070057</nativehr><nativestack></nativestack> ArgumentException

If you encounter an error like this:

<nativehr>0x80070057</nativehr><nativestack></nativestack> ArgumentException


While developing query with Linq To Sharepoint, most probably you have a wrong target platform; you must target ALL your project to x64 platform.

Monday, March 12, 2012

Sharepoint 2010 DataFormWebPart doesn't show all the items

Some time ago I developed a custom page with a DataFormWebPart paged and groping enabled; with my surprise I found that clicking on "next page" icon a javascript error was raised on the javascript console.

After some investigation I discovered that the javascript embedded into the <a> element was malformed.

The charter ' was correctly encoded %27 in the source html but when redered by the browser and then decoded the javascript function fail.

The code below is a simple workaround for the bug

Wednesday, February 29, 2012

Expected hex 0x in '{0xdddddddd, etc}

Sometime, developing a Sharepoint custom page with xslt view and selecting a row, results is this javascript error:

Expected hex 0x in '{0xdddddddd, etc}

Apparently there are some missing/malformed GUID into the xslt control.
Below the step necessary to resolve this issue:

1. Grab the guid of the AllItems.aspx page of the linked datasource list
2. Open the page and select the xslt view, add a new property named ViewGuid and set with the previous value
3. Change the value of the property Name of the XmlDefinition node with the previous value.

Side Effects:
If you have removed link for add new element this is restored.

Friday, February 24, 2012

Read Sharepoint Lookup field

Sharepoint stores the informations in Lookup fields this way:

ID;#VALUE

Sometimes we need read just the value of id. Someone takes the field value as a string and split the content using Split or IndexOf. This technique is valid but..., if Microsoft changes the way the lookup information are saved ?

To read a lookup field you can use SPFieldLookupValue

Using SPFieldLookupValue we can split the values of the lookup field in a simpler way



Enjoy!

Wednesday, February 22, 2012

Sharepoint ConnectionString from EventHandler

In some cases, developing a Sharepoint Event Handler, we needs to read the web.config; the code below solves the problem


This is the link to my Old Post

Query Sharepoint 2010 list via Javascript

Query Sharepoint 2010 list using JavaScript and Client ObjectModel


To read items from a Sharepoint list within a custom page you can use Javascript and client object model, below I explain necessary step to achive this.

Add a new page and reference the Object Model on the content of the page (Sp.js), I add also a reference to the jQuery library for the document ready event.

One very important thing is that you give the page time to load the object model javascript, to do this in the document ready function I call executeOrDelayUntilScriptLoaded that can wait for the fully loaded js.

The code I think is pretty clear: in the document ready I call executeOrDelayUntilScriptLoaded which waits for the loading of object model javascript, and after I calls the function getValues.

Function getValues create the sharepoint object model context and query the specified list for item with ID = 1. To the asynchronous function executeQueryAsync you must specify two callback: the first for the success, and the other for the errors.

If the call return without errors you must get values with the function get_item("ColName").
Enjoy!

Thursday, February 9, 2012

ASP.NET strongly typed querystring parameters

To read strongly typed querystring parameters, I wrote a simple extension method that does the "dirty" job conversion
The use is simple:

Saturday, February 4, 2012

Open Sharepoint editing popup via javascript

In some cases, developing within sharepoint 2010, you need to launch through javascript a editing popup for an item. To achieve this functionality you must enter this code snippet:
The url passed to the function must be according to this scheme
http://localhost/<miosito>/Lists//EditForm.aspx?ID=<id>&IsDlg=1
Replacing <mysite>   with link to sharepoint site, or directly with
/Lists//EditForm.aspx?ID=<id>&IsDlg=1
Replace <id> with the id of the element Enjoy!