Wednesday, July 17, 2013

“Failed to get value of the “Attachments” column from the “Attachments” field type control. See details in log. Exception message: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)”

The attachment issue comes after customization of NewForm.aspx/EditForm.aspx page. After Customizing page even you have not attached any attachement the following error message showing on click of save button:-
“Failed to get value of the “Attachments” column from the “Attachments” field type control. See details in log. Exception message: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)”

Resolution:-
Disabled attachment option from list
Go to list --> settings --> advance settings ---> disable attachments.

OR

If you want the attachment column to be present, open page in sharepoint designer and findout the below tag and replace it....

<TemplateName xmlns="http://schemas.microsoft.com/WebPart/v2/ListForm">ListForm</TemplateName>

To

<TemplateName xmlns="http://schemas.microsoft.com/WebPart/v2/ListForm">ListForm2</TemplateName>

Friday, July 5, 2013

SharePoint Lookup field: - Behaves differently when items greater than 20

SharePoint Lookup field: - Behaves differently when items greater than 20
Lookup column having less than 20 items:
If your lookup column having 20 or less items, the lookup column rendered like a normal dropdown filed (i.e. if you checked the source code of the page, you will get HTML tag <Select title=”File ID”…..) as shown in below images.
1.       The below image showing no. of items less than 20
2.       The below image showing source code for the page

Lookup column having more than 20 items:
If your lookup column is having more than 20 items, the source code automatically changed and complicated in IE browser. In FireFox and other browsers the lookup column with more than 20 items still gets same HTML source i.e. <Select tag .  The images are shown in below:
1.       The below image showing no. of items greater than 20
2.       The below image showing source code for the page
When lookup column has more than 20 items in IE it gets generated INPUT text box with an image. The input field on the other hand having lots of event handler like onfocusout, onkeypress, onkeydown. One of the attributes of input tag is also “Choices” which contains all the ids and values of lookup separated by “|” character. The image next to Input field has an “Onclick” event that triggers the select and selected value pass to the attribute “Value”.

Tuesday, April 30, 2013

Remove hyperlink from lookup column in Dataview webpart in Sharepoint 2010

When you used lookup column in the list and implemented it in custom dataview webpart, the hyperlink appears on the lookup field value.

To remove the link from lookup field used the following tag:-

Just you have to replace with

<xsl:value-of disable-output-escaping="yes" select="@Teams"/>

By:

<xsl:value-of disable-output-escaping="yes"
select="substring-after(substring-before(substring-after(@Teams, 'ID='), '&lt;'), '&gt;')"/>


If you have added multiple selection lookup value in your list, and you want to remove hyperlink from field, the above trick will not work. For that we required to more customise the XSLT and used the following code:-

In multiple selection lookup value shows in data view web part:-

Team1; Team2; Team3; Team4

We will format it to:-

Team1
Team2
Team3
Team4

Using the following code:-

Add the below template to your data view web part:-

<!—Semicolon delimit start -- >
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text,$replace)" />                
<xsl:value-of select="$by" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)" />
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!—Semicolon delimit End -- >

<!—Remove Hyperlink start-- >

<xsl:template name="deleteAnchorTags">
<xsl:param name="Anchor"/>
<xsl:choose>
<xsl:when test="contains($Anchor, '&lt;')">                                    
<xsl:value-of select="substring-before($Anchor, '&lt;')"/>
<xsl:call-template name="deleteAnchorTags">
<xsl:with-param name="Anchor" select="substring-after($Anchor, '&gt;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Anchor"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!—Remove Hyperlink End-- >


And replace your tag with:-

<xsl:value-of disable-output-escaping="yes" select="@Teams"/>

By:-

<xsl:variable name="onlyText">
<xsl:call-template name="deleteAnchorTags">
<xsl:with-param name="Anchor" select="@Teams" />
</xsl:call-template>
</xsl:variable>
 <xsl:variable name="thisRow">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="$onlyText" />
<xsl:with-param name="replace" select="';'" />
<xsl:with-param name="by" select="'&lt;br/&gt;'" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$thisRow" disable-output-escaping="yes"/>


Happy coding..... :-) :-) :-)

Thursday, January 17, 2013

Ribbon menu missing on page load after customisation


After  Customisation in sharepoint pages ribbon menu missing on page load for perticular webpart.

            In sharepoint 2010, if you have more than one webpart on webpart page, the ribbon disappears because SharePoint doesn't know which web part to display ribbon for. This is by design because if you have a document library web part and list web part on the same page, the ribbons are obviously differ for the two and sharepoint needs to know which webpart to display the ribbon for.

To avoid the above problem use the following javascript.

<Script>
setTimeout(function()
{

var obj = document.getElementById("MSOZoneCell_WebPartWPQ3");
if(obj != null)
{

var obj1 = new Array()

obj1["target"] = obj

obj1 ["srcElement"] = obj

WpClick(obj1)
}
},2000)

</Script>

Overlay calendar items open in new window instead in Modal Popup

When you create overlay calendar view for combined 2 or 3 views especially for colour coded calendar, if you create event with category and click on it, it will open in popup which is by default function of SharePoint.
If you create event without category column value and click on it, it will open in new window. To remove the above problem use the below javascript.

<script src="/sites/CUEDemo/Code%20Library/jquery-1.8.3.min.js" type="text/javascript"></script>

<script type="text/javascript">
// load our function to the delayed load list
                _spBodyOnLoadFunctionNames.push('calendarEventLinkIntercept');

                // hook into the existing SharePoint calendar load function.
                function calendarEventLinkIntercept()
                {
                                if (SP.UI.ApplicationPages.CalendarNotify.$4a)
                                                {
                                                var OldCalendarNotify = SP.UI.ApplicationPages.CalendarNotify.$4a;
                                                SP.UI.ApplicationPages.CalendarNotify.$4a = function ()
                                                {
                                                OldCalendarNotify();
                                                bindEventClickHandler();
                                                }
                                                }
                                if (SP.UI.ApplicationPages.CalendarNotify.$4b)
                                                {
                                                var OldCalendarNotify = SP.UI.ApplicationPages.CalendarNotify.$4b;
                                                SP.UI.ApplicationPages.CalendarNotify.$4b =  function ()
                                                {
                                                OldCalendarNotify();
                                                bindEventClickHandler();

                                                } 
                                }
                  // future service pack change may go here!
                  // if (SP.UI.ApplicationPages.CalendarNotify.???)
                }

                function bindEventClickHandler()             {
                                $('.ms-acal-rootdiv a').click(function(){EditLink2(this,'WPQ2');return false;});
                }



</script>

Avoid Contributor user to edit home page in sharepoint 2012 Team site

This is contributor permission issue(sharepoint 2012 bug). Normally when you create Sharepoint 2012 team site, the home page by default create under "SitePages" library.

The contributor users on site can easily modify home page and change setting of webpart and layouts.
The key to that issue is in the description "customize Web Part Pages in document libraries ", and it's the "in document libraries " that's the problem. When a page is in a library, it is treated as a file or document. If the user has "contribute" or Edit permissions to the library storing the page then they have the right to edit the page.
In 2007 the home page (default.aspx) was stored outside of a library, so "contributors" did not have edit rights by default. In 2010 Team Sites the home page is stored in the SitePages library that inherits permissions from the site, and therefore contributors have edit rights.
The solution is to set custom permissions in the pages library. Just break inheritance and grant your team members View only rights and the Site Owners full control.

Happy Coding.......... :-)

Thursday, August 9, 2012

SharePoint 2010 Webpart page not showing Quick Launch

Some times SharePoint 2010 site newly created webpart page, publishing page does not show Quick launch bar(Left navigation panel) on page. It might be hide by some css available on page or some content place holder override by master page.

To solve the above issue, follow the following steps:-
1) Open your site in sharepoint designer.
2) Open your webpart page in advanced mode.
3) Remove the below content place holder.
   
<asp:Content ContentPlaceHolderId="PlaceHolderNavSpacer" runat="server">
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server">
</asp:Content>
 
4)Save the page, it will show the Quick launch bar on page. If it is not showing on page, then remove the below CSS available on page:-
 
<style type="text/css">
body #s4-leftpanel {
    display:none;
}
.s4-ca {
    margin-left:0px;
}
</style>

5) Save the page, quick launch bar appear on page.