Top Menu

Wednesday, March 10, 2010

Attachments in DataView


By Dafault DataView control dont display attachments and when you add attachment column it displays true/false.


Here is the solution by Brandt Fuchs: http://dbweb.sbisite.com/blogs/bf/Lists/Posts/Post.aspx?ID=19

Perform following steps:

1. Add DataView control in your page.
2. Add an empty column.
3. Add following code:











Monday, March 8, 2010

Adding JavaScript to SharePoint Form Field


Many time in my current project I felt the need of adding javascript to the SharePoint Form Fields to trigger my custom function in order to perform some calculation and other stuff.
Luckily I found the following blog and it sloved my Javascript problem.

URL: http://webborg.blogspot.com/2008/04/add-functions-and-events-to-sharepoint.html

When you add the javascript mentioned in the above blog in the bottom of your page, do call your custom function again at the end because if ur page postbacks and reload (due to some missing required field or any other reason) dropdown change event wont fire. So here is the updated code:

function getField(fieldType,fieldTitle) { 
    var docTags = document.getElementsByTagName(fieldType); 
    for (var i=0; i < docTags.length; i++) { 
        if (docTags[i].title == fieldTitle) { 
            return docTags[i] 
        } 
    } 
} 
 
function DisplayMessage()
{
 alert('Hello World');
}

//Add JavaScript to Decision Column
getField('select','Decision').onchange = function() {DisplayMessage()};

//Add additional call
DisplayMessage();
Line 19 is the additional call to the function.
Above code will add onchange event to choice type SharePoint field and each time the selected value is changed, DisplayMessage() will be triggered.


Wednesday, December 16, 2009

SharePoint 2010 - List Relationship

Today, I got the access to the SharePoint 2010 Beta and guess what I saw? The most beautiful thing that could happen to the SharePoint lists...Relationships. Just like Database relations. :o)

Lets take a look at the following screen shot: While creating a lookup column in a list, I noticed following enhancements:

  1. I can choose ID Column from the parent list.Very very important for building reports/views.
  2. If I choose other column (Title etc), I still can include ID as an additional field.
  3. Restrict & Cascade delete option. :o) If I choose restrict and want to delete parent item, having child items...it will not allow me to do so. If I choose cassade and want to delete parent item...it will delete all the child items along with the parent.

SharePoint 2010 Lists rock!

Friday, December 11, 2009

Join Lists Using SharePoint Designer 2007

Background:
There is no parent-child relationship support in MOSS 2007 lists by default. But as a developer, we all know it is the most common functionality while storing and displaying the data. Following is the technique that I discovered somewhere on the internet to display the data using DataView Control in SharePoint Designer(while developing reports for my last project), but unfortunatily I lost the original source and thought to reproduce it in my blog with some enhancements.

Implementation:
Following are the steps to perform Inner Join on two lists using DataView Control in SharePoint Designer:

1. We need following two lists(with data in them):
  • Department (ID, Title)
  • Student (ID,Department_x0020_ID, Title)


  • 2. Open SharePoint Designer and create a new ASPX page.

    3. Create a linked datasource by following steps:
    1. Select Create a new Linked Source... from Data Source Library tab.

    2. In Data Source Properties dialog, select Configure Linked Source... button.

    3. From Link Data Sources Wizard, select Students and Department Lists and hit Next.

    4. Choose Join the contents... option and select Finish.

    5. Then select OK to get the New Data Source.

    6. Expand the New Data Source and select Show Data option.

    7. Under Data Source Details tab, you should see both lists (Department and student).


    4. Insert a Data View control into the ASPX page.
    5. Under Data Source Details tab, expand the Students list and drag and drop the Title column to Data View control and it will display all the students.
    6. Now place your cursur in Title column and select Table -> Insert -> Column to Right. In this column we will display Department.Title.
    7. Place your cursor on the first row of new column, select Title Column from Department list and select the Insert selected field as... button and choose Joined Subview opion.
    8. In Join Subview dialog, select Department_x0020_ID = ID and hit OK. (Pic 12)
    9. Thats it :o).
    10. Play with the HTML to make it look like a report.

    Sunday, November 15, 2009

    Get the actual error message in SharePoint Site Page



    In web.config change the following:

    1. CallStack="false"

    2. <customErrors mode="On" />

    Now refresh the page to see the actual ASP.NET error message.

    Before:


    After:

    Monday, November 9, 2009

    Security on SharePoint Website Controls with SPSecurityTrimmedControl


    I came across a requirement while building a site in SharePoint 2007 where I have to display the left menu only to administrator and Thanks to Mark Wagner for his quick and to the point post on SPSecurityTrimmedControl.

    What exactly I did was:

    1. Open the Default.aspx in SharePoint Designer.
    2. Select the left menu and then select Create Custom Content.
    3. Arranged the tags as follow:

    <asp:content contentplaceholderid="PlaceHolderLeftNavBar" id="Content2" runat="server">
    <sharepoint:spsecuritytrimmedcontrol permissionsstring="ManageWeb" runat="server">
    
    All the divs and HTML for the menu goes here.
    
    </sharepoint:spsecuritytrimmedcontrol>
    </asp:content>
    

    Now the menu will only appear for users having administrator rights.
    Note: Also, you can directly implement this in Master Page for hiding View All Site Content.

    Tuesday, July 14, 2009

    SharePoint 2003 to MOSS 2007 Migration

    Senario: You have two servers. One has SharePoint 2003 and other have MOSS 2007 installed. You want to migrate a website collection from SharePoint 2003 to MOSS2007.
    Scan the SharePoint 2003 Website
    1. PreScan Tool
    prescan.exe /c preupgradescanconfig.xml /v http://intranet2. Check the Orphan Records
    stsadm -o databaserepair -url http://intranet -databasename MyIntranet_Site3. Delete the Orphan Records
    stsadm -o databaserepair -url http://intranet -databasename MyIntranet_Site -deletecorruption4. Check the Orphan Records
    stsadm -o databaserepair -url http://intranet -databasename MyIntranet_Site
    5. PreScan Tool
    prescan.exe /c preupgradescanconfig.xml /v http://intranet

    Content Database Migration
    1. Go to SQL Server and create the website’s Content Database's backup after making it read only.
    2. Copy the database's backup file to the New Server.
    3. Create a new Database in New SQL Server and Restore the database (overwrite).

    Create the MOSS 2007 Website
    1. Create the WebApplication in MOSS 2007. Don’t create any site collection.
    2. Remove the content application database
    stsadm.exe -o deletecontentdb -databasename WSS_Content_Intranet_80 -url http://newintranetsite/
    3. Attach the new database
    stsadm.exe -o addcontentdb -url http://newintranetsitet/ –databasename Portal_Site_Restore

    Ref 1: http://farhanfaiz.wordpress.com/2008/05/23/sharepoint-upgrade-database-migration
    Ref 2: http://sharemypoint.blogspot.com/2007/04/prescanexe-finished-with-failure.html

    Official SharePoint Documentation

    I have recently contributed to the official SharePoint documentation for developement. Check it out here: https://docs.microsoft.com/en-us...