Thursday, April 28, 2016

How to get Image from Picture Library using REST API

I used REST API to get the Image form Picture Library and display my Banner Dynamically.

I used normal RESTful HTTP url like asusual Path and Query string param in the sequence of SELECT, FILTER and ORDER BY accordingly  but I am not able to get "EncodedAbsUrl"  in the result.

After I googled I got some idea, form some forums.

Like I used SELECT statement as a last querystring param, like below:

http://sharePointchild.com/_api/Web/Lists/GetByTitle('HomeBanner')/Items?filter=IsActive%20eq%201&$top=1&$orderby=IsActive%20desc&$select=EncodedAbsUrl

Code:

$(document).ready(function(){

var siteColUrl=_spPageContextInfo.siteAbsoluteUrl;

$.ajax({
method:"GET",
headers:{"Accept":"application/json; odata=verbose"},
url:siteColUrl+"/_api/Web/Lists/GetByTitle('HomeBanner')/Items?filter=IsActive%20eq%201&$top=1&$orderby=IsActive%20desc&$select=EncodedAbsUrl",
success: function (data) {

        completeBannerdata(data);
   }
   ,
    error: function (error) {

              failiureBannerdata(error);
         
        }

});

})

function completeBannerdata(data)
{

var items = data.d.results;
if(items.length>0)
{
       $('#imgBanner').attr('src', items[0]["EncodedAbsUrl"]);
       }
}

 function failiureBannerdata(error)
 {

 }

SharePoint 2013 Error When Trying to Create New Publishing Page

I have Own content type which is base by Article pages, and associated with my Pages Library.
The library contains "articles" folder, we are placing all article relavant pages under this folder.
When user create a new page via "Add a page" link, we are moving that page from root folder to article folder via content organizer rule.

For testing, when I try to create a new Publishing page via "Add a Page" option, it got the error as below:

Invalid field name. {50631c24-1371-4ecf-a5ae-ed41b03f4499}   

I googled and got some reference,
we needs to add some of the fields to our content type.

Solution:

1. Go to the Content type page
2. Add the below columns to your content type:
    a. Hide from Internet Search Engines 
    b. Hide physical URLs from Search
    c. Meta Description
    d. Meta Keywords

set yes, for update all content types inheriting from this type. If required.

Click Ok.

Thursday, April 21, 2016

How to View PDF & HTML Files in Browsers in SharePoint 2013

The more secure way is to display PDF and HTML file in the browse are ShaerPoint portal. Add the MIME type of PDF and HTML file into your WebApplication's AllowedInlineDownloadedMimeTypes. Instead of enable the Permissive Option at Browser Handling section in WebApplication's General Settings.

Execute the below script in SharePoint PowerShell cmdlets:

$webApp = Get-SPWebApplication("http://www.samples.com")
$webApp.AllowedInlineDownloadedMimeTypes.Add("application/pdf")
$webApp.AllowedInlineDownloadedMimeTypes.Add("text/html")
$webApp.Update()