Monday, November 14, 2011

Sharepoint Gotchas

Share/Save/Bookmark


- Code to retrieve list items, if run under elevated block(SPSecurity.RunWithElevatedPreviliges) it always returns list items that are only checked in but not checked out.

- To know the current style for a summary link webpart use attribute @Style
- How to check if the page is in edit mode in XSLT in summary link webpart?
    Declare the below namespace and the parameter.
    xmlns:slwp="urn:schemas-microsoft-com:SummaryLinkWebPart"
   <xsl:param name="slw_iseditmode" />
 
   use <xsl:if test="$slw_iseditmode='True'">  to check if the page is in edit mode.

- Cancel approval do not update the status of the item from pending to draft when the workflow is a custom designed using Sharepoint Designer(SPD). In other cases(OOTB page approval or Visual Studio workflow) it works.

  Subscribe

Saturday, September 3, 2011

Remove format when copy paste in rich text editor

Share/Save/Bookmark

How do i avoid the formatting that comes along when i copy paste content from a site or word document to the Rich Text Editor (RTE) field in sharepoint? Ofcourse RTE already have an option Clear Formatting that can be used to clear after pasting the content,, but i do not want the format to be copied at first. So after digging into SP.UI.RTE.js and googling i have come up with a small script that will not paste the markup but only text.


    //Disable the RTE paste option. Restricts to "Paste Plain Text"
    function disableMarkupPasteForRTE()
    {
     Type.registerNamespace("RTE");
     if (RTE)
     {
      if(RTE.RichTextEditor != null)
      {
       RTE.RichTextEditor.paste = function() { RTE.Cursor.paste(true); }
       // Handle Ctrl+V short cut options in rich text editor
       RTE.Cursor.$3C_0 = true;
      }
     }
    }

I used the below standard sharepoint javascript function that will run the above or any javascript function on load of page.

    _spBodyOnLoadFunctionNames.push("disableMarkupPasteForRTE");


 Subscribe

Saturday, March 19, 2011

Webpart Connections in Sharepoint 2010 PageLayouts

Share/Save/Bookmark
Days, come back to work with sharepoint designer 2010 developing pagelayouts,
In the process of developing the page layouts it is observed that the webparts that are placed inside
the tags do not work after a page is created based on the pagelayout though the webpart connection is already set.
So i have to move the webparts outside of UIVersionContent tags to have the connections work in pages.


Are you wondering what is UIVersion? This is something new in 2010 w.r.t visual design, which indicates that the elements(part of pages) that you are developing is meant to be compatible for 2007/2010 by setting the attribute UIVersion=3/4


 Subscribe

Sunday, February 20, 2011

Access Page field in Dataform webpart

Share/Save/Bookmark

It’s the first time i got a chance to work on the so called, Swiss knife of SharePoint "Dataform" webpart .
I have a requirement to pull the data (different sitecollection) using dataform webpart
and filter the data based on the field value of the page(created based on page layout) where the webpart is placed on.

As it is cross site querying, I have to add a new SOAP datasource and configure it to dataform webpart. I could pull the data,
so how to access the page field value inside the dataform webpart xsl?
ParameterBinding is the solution for it.
It allows you to declare the external parameters that can be accessed by dataform webpart.

So how do we get this work??
  
Create datasource :

There are many feeds lying out there on web that would help you to create a soap datasource and pull data using dataform webpart with the help of Sharepoint Designer.

Define ID attribute:

Make sure ID attributes are set for the page fields that you want to access in dataform webpart. For example i want to access a look up field that is part of a pagelayout which is defined as

ParameterBinding:

In Sharepoint designer 2010 click on the dataform webpart to see the its properties/settings
on the ribbon. Click on parameters on options tab as shown below


Name the parameter "lookupFieldParam" that should be binded to the pagefield control
holding the id PageFieldSrc as selected in the screen. Default value for this new param can also be selected.



After you click on ok, designer adds the necessary param definition xsl tags to the dataform webpart. The place you should care about to have it is under

<parameterbindings>
 ....
<ParameterBinding Name="lookupFieldParam"  Location="Control(PageFieldSrc,ItemFieldValue)" DefaultValue="ABC" />
</parameterbindings>

Now it’s time to test our efforts...

Add the below xsl tag under row template and create a page based on that pagelayout to see if the parameter is fetching the value.

<xsl:value-of select="$lookupFieldParam" />
 Note $ reference here.

So now we have page field value in dataform webpart, how to use this to filter the data in dataform webpart will be drafted in my next version of this post.

 Subscribe