Showing posts with label Sharepoint 13. Show all posts
Showing posts with label Sharepoint 13. Show all posts

Friday, November 27, 2015

SharePoint Migration Lookup error

There was site in SharePoint 2010 and I was planning to move it to SharePoint 2013 version by performing a Content db migration .

The site had a list which consists of lookup columns ,these were lookup to other list.But the point here was that these columns were hidden while it was created through element.xml in the solution .The list was working fine in SharePoint 2010 ,But when I migrated the 2010 site to SharePoint 2013 the link of the lookup is lost and the data is been displayed as a text field Eg: "#2;lookupValue" etc .
This was creating few problems in my solution due to mismatch in the values of the list itms .I had to fix the lookup column .Below is the resolution to this migration error



I placed the below code in Content Editor WebPart and made the field readable,This changed the column back as lookup .Later you can change the column to readonly =true


<content id="Main" contentplaceholderid="PlaceHolderMain" runat="server"></content><script language="ecmascript" type="text/ecmascript">
        var fieldCollection;
        var field;
        var list;
        function UpdateField() {
            var clientContext = SP.ClientContext.get_current();
            if (clientContext != undefined && clientContext != null) {
                var webSite = clientContext.get_web();
                this.list = webSite.get_lists().getByTitle("ListA");
                this.fieldCollection = list.get_fields();
                this.field = fieldCollection.getByTitle("Column1");
                this.field.set_readOnlyField(false);
                this.field.update();

            clientContext.load(this.fieldCollection);
            clientContext.load(this.field);
                clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess), Function.createDelegate(this, this.OnLoadFailed));
            }
        }
        function OnLoadSuccess(sender, args) {
            alert("Field deleted successfully.");
        }
        function OnLoadFailed(sender, args) {
            alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
        }
</script><input type="button" id="btnUpdateField" onclick="UpdateField()" value="Change ReadOnly"/> 

Friday, May 9, 2014

Add Sharepoint Navigation links with audience targeting through powershell

Below is the powershell command to add Navigation links in SharePoint.This was tested in SharePoint 2013 environment.This script will check if the link is present in the site if not it will add the links along with audience targeting



$snapin = Get-PSSnapin | Where-Object { $_.Name -eq "Microsoft.SharePoint.Powershell" }

if ($snapin -eq $null) {

Write-Host "[INIT] Loading SharePoint Powershell Snapin"

Add-PSSnapin "Microsoft.SharePoint.Powershell"


}

 
 
$Web = Get-SPWeb http://testWebapplication:7777

$TopNav = $Web.Navigation.TopNavigationBar

Write-Host -ForegroundColor Green "Creating Navigation links ......................."



$Heading = $TopNav | where { $_.Title -eq "Link1" }

if($Heading -eq $null)



{
 
$newLink = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode -ArgumentList @("Link1", "/Lists/CreateNewPublication/DocProjects.aspx");

$Heading = $Web.Navigation.TopNavigationBar.AddAsLast($newLink)

$Web.Update()





}

 
 
$Heading = $TopNav | where { $_.Title -eq "Search" }

if($Heading -eq $null)


{
 
$newLink = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode -ArgumentList @("Search", "/SitePages/Search.aspx");

$Heading = $Web.Navigation.TopNavigationBar.AddAsLast($newLink)

$Web.Update()


}
 
$Heading = $TopNav | where { $_.Title -eq "Google" }

if($Heading -eq $null)


{
 
$newLink = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode -ArgumentList @("Google", http://www.google.com);

$Heading = $Web.Navigation.TopNavigationBar.AddAsLast($newLink)

$Web.Update()


}
 
$Heading = $TopNav | where { $_.Title -eq "Yahoo" }

if($Heading -eq $null)



{
 
$newLink = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode -ArgumentList @("Yahoo", http://yahoo.co.in);

$Heading = $Web.Navigation.TopNavigationBar.AddAsLast($newLink)

$Heading.Properties["Audience"] = ";;;;" + "IK,IL,R,C"

$Heading.update()

$Web.Update()





}
 
$Heading = $TopNav | where { $_.Title -eq "Reports" }

if($Heading -eq $null)



{
 
$newLink = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode -ArgumentList @("Reports", "/SitePages/Reports.aspx");

$Heading = $Web.Navigation.TopNavigationBar.AddAsLast($newLink)

$Heading.Properties["Audience"] = ";;;;" + "PM,TL,IL,C"

$Heading.update()

$Web.Update() 



}
 
  $Heading = $TopNav | where { $_.Title -eq " Help" }

if($Heading -eq $null)

{
 
$newLink = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode -ArgumentList @(" Help", "/Lists/HelpLibrary ");

$Heading = $Web.Navigation.TopNavigationBar.AddAsLast($newLink)

$Web.Update()


}
 
Write-Host -ForegroundColor Green "Navigation link creation completed"

Pause

Wednesday, January 22, 2014

MSOCAF error- Remove inline code present in the aspx pages


Remove inline code present in the aspx pages. Inline code is not recommended within a site definition due to the issues involved with the code no longer rendering as soon as the page is customized. Inline code is supportable if included on a page in the _layouts directory. Inline code should not be allowed through the PageParserPath exclusion, except in extremely rare circumstances, because it can be modified without going through any review process. As a result, it represents a danger to the environment’s performance and security. Adding PageParserPath element to the web.config files is not allowed. Modifying these files may ‘break’ SharePoint in some way if you change the wrong part of the file
 
 
Found this error while running the MSOCAF on my project having aspx file been deployed to Layouts folder.
 
This error is mainly due to using the <script> tag in your ascx file as below to refere your "js" files in different location like site assests,layouts or any other location
 
 
<script src="myscripts.js"></script>
 
This tag throws the above error
 
This can be resolved by using the tags as mentioned below
 
<SharePoint:ScriptLink ID="ScriptLink1" Name="~sitecollection/siteassests/myscripts.js" runat="server" />
 
 

Monday, October 28, 2013

Sharepoint 2013 reports + An unexpected error occurred while connecting to the report server. Verify that the Reporting Services Service Application mapped to this web application is available OR the report server is available and configured for SharePoint Integrated mode

An unexpected error occurred while connecting to the report server. Verify that the Reporting Services Service Application mapped to this web application is available OR the report server is available and configured for SharePoint Integrated mode. --> The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+msbin1). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<title>IIS 8.0 Detailed Error - 500.19 - Internal Server Error</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;}
code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;}
.config_source code{font-size:.8em;color:#000000;}
pre{margin:0;font-size:1.4em;word-wrap:break-word;}
ul,ol{margin:10px 0 10px 5px;}
ul.first,ol.first{margin-top:5px;}
fieldset{padding:0 15px 10px 15px;word-break:break-all;}
.summary-container fieldset{padding-bottom:5px;margin-top:4px;}
legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;}
legend{color:#333333;;margin:4px 0 8px -12px;_margin-top:0px;
font-weight:bold;font-size:1em;}
a:link,a:visited{color:#007EFF;font-weight:bold;}
a:hover{text-decoration:none;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0'. --> The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+msbin1). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<title>IIS 8.0 Detailed Error - 500.19 - Internal Server Error</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;}
code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;}
.config_source code{font-size:.8em;color:#000000;}
pre{margin:0;font-size:1.4em;word-wrap:break-word;}
ul,ol{margin:10px 0 10px 5px;}
ul.first,ol.first{margin-top:5px;}
fieldset{padding:0 15px 10px 15px;word-break:break-all;}
.summary-container fieldset{padding-bottom:5px;margin-top:4px;}
legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;}
legend{color:#333333;;margin:4px 0 8px -12px;_margin-top:0px;
font-weight:bold;font-size:1em;}
a:link,a:visited{color:#007EFF;font-weight:bold;}
a:hover{text-decoration:none;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0'. --> The remote server returned an error: (500) Internal Server Error.



Found this error when tried to use the Report Viewer webpart in SharePoint 2013 page after the "REPORT SERVICE was configured in SHAREPOINT INTEGRATED MODE"


Solution: Run the SP1 for SQL server 2012

Problem: the report viewer try to access web service from this location -->C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\WebServices\Reporting

But if you have not applied SP1 for SQL2012 you will find this Reporting folder only in 14 Hive not in 15 hive. After the update of Report service in SharePoint integrated mode from SP1 you will  be able to see the Reporting folder in 15 Hive too.


For Report to work in SharePoint integrated mode in SharePoin 2013 SP1 for SQL 2012 is very much required

Wednesday, October 16, 2013

Connect custom webpart to List View Webpart in SharePoint 2013 .Connected Webparts send parameter from Custom webpart

I had a requirement to sending a parameter from custom webpart and sending it to a report view webpart .This code can also be used to connect any custom webpart with List view webpart.

All you need to do is
1)Open visual studio
2)Create a project
3)Using the template "Webpart" which is grouped under Sharepoint section in VS create a item
named "FilterWebpart".

Use the below code in FilterWebpart.cs



using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using System.Collections.ObjectModel;

namespace ProviderWebpartVS.FilterWebpart
{
    [ToolboxItemAttribute(false)]
    public class FilterWebpart : System.Web.UI.WebControls.WebParts.WebPart, ITransformableFilterValues
    {

        string propertyvalue = "BSW3";     

        #region ITransformableFilterValues Members

        public bool AllowAllValue
        {
            get { return true; }
        }

        public bool AllowEmptyValue
        {
            get { return true; }
        }

        public bool AllowMultipleValues
        {
            get { return false; }
        }

        public string ParameterName
        {
            get { return "ConnectionProperty"; }
        }

        public System.Collections.ObjectModel.ReadOnlyCollection<string> ParameterValues
        {
            get
            {
                string[] values = new string[] { propertyvalue };
                return new ReadOnlyCollection<string>(values);
            }
        }

        [ConnectionProvider("Connection Property Filter", "ITransformableFilterValues", AllowsMultipleConnections = true)]
        public ITransformableFilterValues SetConnectionInterface()
        {
            return this;
        }

        #endregion
        protected override void CreateChildControls()
        {
        }
    }
}

4)Now deploy the solution into a sharepoint site.
5)Open the site in browser 
6)Add this custom webpart .
7) Also add report view webpart which has parameters or any other list view webpart
8)Edit the webpart -->click -->Connection -->Connect to any webpart on the page.A configuartion window popups on the page where you can configure which parameter is connected to which webpart.


9)Here in this example propertyvalue will be sent as parameter to other webpart.You can change it to take arrary of string in "string[] values"  as shown in code.You your custom logic here to fill the data into string[] values.



Thanks to links below which helped in achieving this

http://blogs.msdn.com/b/edhild/archive/2007/03/28/how-to-build-a-custom-filter-provider-web-part.aspx