Steps to change SharePoint Item Context Menu to your own Column

Steps to enable Context Menu from SharePoint Designer:

  • Navigate to the List that you have to do the customization.
  • Select the Modify View Option and then select Modify in SharePoint Designer.
  • Select the Column that you need to add the context menu, then you will get a small > symbol indicating more options available.
  • Select the Check Box “Show List Item Menu”.
  • Save and now view the list from the browser.

Steps to enable Context Menu from the Schema.xml file?

  • Open the list as a template
  • Set “ListItemMenu” attribute for the required field to “TRUE”. (The modification should be done to the FieldRef that is in Default View of the list)

How to do this using Powershell – Check this link 

http://www.ilovesharepoint.com/2008/08/add-sharepoint-list-item-context-menu.html

How to join two SharePoint lists with inner join functionality

Create two SharePoint lists

a)     Customer (Title)

b)    Orders (Title, and Customer)

Here are my lists –

Open the your site using SharePoint Designer (SPD), and add a new page under site pages library

In SPD, go to Data Sources. In the window that appears; create a new Linked source as shown below:

Click on “Configure Linked Source” and go ahead and add both “Customers” and “Orders” and click “Next”

Make sure that you choose to join the contents of the two data sources as shown below

Give it a meaningful name in the “General” tab.

Now Insert an Empty Data View in your page and put the cursor on your data view

Now from the “Data Source Details” pane, select Title from Customer List. And choose – Insert Selected Field as “Multiple Item View” as shown below:

After this your page will look like this

Now add a column to the right side and place the cursor in front a particular value – Say “Joseph”, and now in the Data Source Details Pane, Select Orders –> Title, and choose to insert as “Joined SubView” in the menu shown below:

Specify Join information/condition as shown below:

That’s it! Format it a little bit, run the ASPX – looks like this

How to filter a lookup column in SharePoint?

As of now there is no way in Out of Box which will support filtering a lookup column to show only limited set of entries based on certain condition.

Following are the steps to create filtered lookup column:

  • In order to start we will create two lists where one is our main lookup list (Category List) and other is the list that would use the lookup list as a lookup column (User Interest).
  • Add some data in the Category List as shown in image below:

  • Important Step – In the list (User Interest) create a Single Line of Text column (Active Interest) and Not a Lookup column. If you use a Lookup column, you will get an error when trying to save new or updated entries.
  • In SharePoint Designer go to the Data Source Library tab. Right click on the lookup list (Category Config) and select Copy and Modify
  • In the Data Source Properties popup window, on the General tab enter the Name (FilteredLookup).

  • On the Source tab under Query click on the Filter button and enter your Filter Criteria

  • Click OK. You may also want to the Sort by clicking on the Sort button. Click OK
  • Once you have done with new list creation named FilteredLookup. XML file for the same is created which you find at the path All files / _catalogs / fpdatasources /

  • ( _ )FilteredLookup.xml [the _ (underscore) may or may not be there]. Choose “Edit file” option after selecting the xml file.
  • Use the SharePoint Designer 2010 to edit XML file(FilteredLookup.xml)
    • Add an id attribute right after the UseInternalName attribute and give it a value (id=”FilteredLookup”)
    • Save the file with your updates but keep the file open
    • Copy the text only from the starting to ending SharePoint:SPDataSource tags. Mine looks like below but yours will be different based on your list guid, the fields, sort, and filter values…

<SharePoint:SPDataSource runat=”server” DataSourceMode=”List” UseInternalName=”true” id=”FilteredLookup” UseServerDataFormat=”true” selectcommand=”&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;Status&quot;/&gt;&lt;Value Type=&quot;Text&quot;&gt;Active&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;ViewFields&gt;&lt;FieldRef Name=&quot;ContentTypeId&quot;/&gt;&lt;FieldRef Name=&quot;Title&quot;/&gt;&lt;FieldRef Name=&quot;File_x0020_Type&quot;/&gt;&lt;FieldRef Name=&quot;Status&quot;/&gt;&lt;FieldRef Name=&quot;ID&quot;/&gt;&lt;FieldRef Name=&quot;Modified&quot;/&gt;&lt;FieldRef Name=&quot;Created&quot;/&gt;&lt;FieldRef Name=&quot;Author&quot;/&gt;&lt;FieldRef Name=&quot;Editor&quot;/&gt;&lt;FieldRef Name=&quot;_HasCopyDestinations&quot;/&gt;&lt;FieldRef Name=&quot;_CopySource&quot;/&gt;&lt;FieldRef Name=&quot;_UIVersion&quot;/&gt;&lt;FieldRef Name=&quot;_UIVersionString&quot;/&gt;&lt;FieldRef Name=&quot;Attachments&quot;/&gt;&lt;FieldRef Name=&quot;_ModerationStatus&quot;/&gt;&lt;FieldRef Name=&quot;FileRef&quot;/&gt;&lt;FieldRef Name=&quot;FileDirRef&quot;/&gt;&lt;FieldRef Name=&quot;Created_x0020_Date&quot;/&gt;&lt;FieldRef Name=&quot;FSObjType&quot;/&gt;&lt;FieldRef Name=&quot;FileLeafRef&quot;/&gt;&lt;FieldRef Name=&quot;ItemChildCount&quot;/&gt;&lt;FieldRef Name=&quot;FolderChildCount&quot;/&gt;&lt;FieldRef Name=&quot;PermMask&quot;/&gt;&lt;/ViewFields&gt;&lt;/View&gt;”><SelectParameters><asp:Parameter Name=”ListID” DefaultValue=”{238AA30C-77ED-424A-8BC5-A11C3EDC77B7}” /></SelectParameters><DeleteParameters><asp:Parameter Name=”ListID” DefaultValue=”{238AA30C-77ED-424A-8BC5-A11C3EDC77B7}” /></DeleteParameters><UpdateParameters><asp:Parameter Name=”ListID” DefaultValue=”{238AA30C-77ED-424A-8BC5-A11C3EDC77B7}” /></UpdateParameters><InsertParameters><asp:Parameter Name=”ListID” DefaultValue=”{238AA30C-77ED-424A-8BC5-A11C3EDC77B7}” /></InsertParameters></SharePoint:SPDataSource>

  • Before starting this step always back up any files you will be editing. In SharePoint Designer, open the file you will be editing such as EditForm.aspx or NewForm.aspx file.
  • Select “User Interest” list from List and Library under Site Objects tab on left. Click on List settings in the toolbar and select “List Form”
  • Give file name for new form, choose the type of form you want to create, if you want your new form to be default then choose “Set as default form for the selected type”, also in case you want to add the same in the list item menu and ribbon then check “Create link in List Item Menu and Ribbon” and provide the link name. Click Ok.

  • In the code view of your form search for the tag <DataSources>
    • After the entry for the existing <SharePoint:SPDataSource … and before the closing </DataSources> tag, paste in the copied SPDataSource from FilteredLookup.xml
    • Your code should look something like this

  • Setup your SharePoint Designer environment to be in Split mode. In Design View select the column that will be used for the lookup field. Right now it will show as a textbox. In Code View the associated code for the textbox will be highlighted. Comment out the textbox.
  • Add the following code right after the commented out textbox and then modify the values in bold to match your particular list:

<SharePoint:DVDropDownList runat=”server” id=”ff2{$Pos}” DataSourceID=”FilteredLookup” DataTextField=”Title” DataValueField=”Title” SelectedValue=”{@Active_x0020_Interest}” __designer:bind=”{ddwrt:DataBind(‘u’,concat(‘ff2′,$Pos),’SelectedValue’,’SelectedIndexChanged’,’ID’,ddwrt:EscapeDelims(string(@ID)),’@Active_x0020_Interest’)}”/>

  • Those are all the steps you need. You can see in the below screen the Active Interest shows only active categories

How to check the selected value is Empty in XSL?

Syntax:

<xsl:choose>
<xsl:when test=”@Public!= ””>
<xsl:value-of select=”@Public” />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select=”concat(‘Not’,’ Applicable’)” />
</xsl:otherwise>
</xsl:choose>

Here “Public” is the column you are retrieving from your SharePoint list

Apply Line Breaks & Disable Special Characters on Multiline Plain Text Column of SharePoint List Custom Display Form

Problem : 

I have a Multiline Text column in SharePoint list with Plain Text format. Which will show the activity log for each record/item. Using workflow/ event receiver I  have to update this column when ever an item created or modified with the below format:

04/03/2012 10:42:17 AM XYZ created this document 
04/09/2012 10:43:07 AM ABC modified this document
04/15/2012 11:38:59 AM LMN modified this document

Everything was working fine till the time I use SharePoint default Display form. When I tried to customize the custom display form(new display form created and set as default display form using SPD 2010) , the line breaks updated in the Multiline Text column was not rendering with line breaks. It was rendering like one paragraph instead of adding line breaks after each activity log as shown below:

04/03/2012 10:42:17 AM XYZ created this document 04/09/2012 10:43:07 AM ABC modified this document 04/15/2012 11:38:59 AM LMN modified this document

Solution :

To resolve this issue, I used the follwoing XSL expression. It was working as expected.

<xsl:value-of disable-output-escaping=”yes”   select=”ddwrt:AutoNewLine(string(@History))” ddwrt:nbsp-preserve = “yes”/>

Here,

  • History is my Multiline Text column in SharePoint list with Plain Text format
  • ddwrt:AutoNewLine is to apply Line Breaks
  • ddwrt:nbsp-preserve is to Disable Special Characters

Happy SharePointing 🙂