Musings by Generator

Sharepoint

Debugging the “Unexpected error occurred” message in SharePoint

by Andrew Shough on Feb.04, 2010, under Sharepoint

Every SharePoint developer has gotten this error message before: “Unexpected error occurred” or something close to that, and has spent hours scratching their heads!

 

I found a little bit of information that has just made my debugging life easier so I thought I better share it. To get more debug information, make the following changes in your web.config file for your SharePoint site, and instead of this generic error, you will get an asp.net error page with stack trace data.

Find:

<SafeMode MaxControls=“200“ CallStack=“false“... />

 

and replace it with:

<SafeMode MaxControls=“200“ CallStack=“true“…/>

 

Also, you will need to set CustomErrors off:

<customErrors mode=“Off“/>

 

The above two changes will give you that wonderful asp.net stack trace error page, allowing you to actually debug your application.

Leave a Comment :, more...

Multiple Office version support in Sharepoint Services 3.0

by Andrew Shough on Dec.19, 2009, under Development, Microsoft Software, Sharepoint

I had an issue in a sharepoint site where users could not open documents if they had Office 2003 installed but could open them if Office 2007 was installed.

So off i went trawling through the code, and eventually found a little bit of script that the previous developers had put in. They had done a massive developer no-no: The assumed the client would be running Office 2007, and therefore, had hardcoded the document click action to use the 2007 Office objects in Sharepoint.

When I checked with the client, and read through the design documentation, there was no mention at all about only using 2007. So my next step was to make it compatible with 2003 and 2007.

The issue here was that I could not just leave it up to sharepoint because they were not doing this properly, they just created a custom web part for these document lists.

So I eventually found a good resource on custom document editing management for Sharepoint Services.

Below is the code that was originally there:

<script type="text/javascript" language="javascript">
function ClientEdit(httpRoot, fileUrl, checkOut)
{
    if (checkOut == undefined || checkOut == null || checkOut == true)
        CheckoutviaXmlhttp(httpRoot, fileUrl); 

    var objEditor = new ActiveXObject('SharePoint.OpenDocuments.3');
    objEditor.EditDocument3(window, fileUrl, false, 'Excel.Sheet'); 

    alert('Selected document opened for edit. \nPush OK button after closing Excel.');
    alert('Verify changes have been saved. \nIncorrectly formatted documents will \nbe automatically rejected.');
}
</script>

This is the code I finally settled on that worked within our sharepoint site:

<script type="text/javascript" language="javascript">
function ClientEdit(httpRoot, fileUrl, checkOut)
{
    try
    {
        if (checkOut == undefined || checkOut == null || checkOut == true)
            CheckoutviaXmlhttp(httpRoot, fileUrl);

        var opened = false;
        var objEditor = null;  

        objEditor=new ActiveXObject('SharePoint.OpenDocuments.2');

        if(objEditor != null)
        {
            opened = objEditor.EditDocument2(window, fileUrl, 'Excel.Sheet');
        }
        else
        {
            objEditor=new ActiveXObject('SharePoint.OpenDocuments.3');

            if(objEditor != null)
                opened = objEditor.EditDocument3(window, fileUrl, false, 'Excel.Sheet');
        }
        if (opened == undefined || opened == null || opened == false)
        {
            alert('Could not open the document.\n Please make sure you have office installed.');
        }
        else
        {
            alert('Selected document opened for edit. \nPress OK button after closing Excel.');
            alert('Verify changes have been saved. \nIncorrectly formatted documents will \nbe automatically rejected.');
        }
        }
        catch(e)
        {
            alert(e);
        }
}
</script>

I had to actually create an Office 2003 Sharepoint object, check if it was created. if so, then open the document, otherwise create an Office 2007 sharepoint object, check if was created and open. Otherwise, I had to tell the user that they do not have a supported version of Office installed on their machine.

This really felt like overkill for me, and I did some extra digging and found out that the most common thing to do would be to use shared workspaces to display document lists and allow for editing but I don’t know enough about sharepoint, I am just learning as I go along. So I have left it as a web part.

1 Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...