Posts Tagged ‘SharePoint2013’

SharePoint 2013: Newly created rendition not working

Recently I was facing an issue with newly created rendition, I created new rendition but the images are not showing the newly created rendition on my development server, also in image picker we not able to see the newly created rendition.

After waiting for some time as well my newly created rendition not worked. After some investigation we figured out that as renditions was previously working fine means blob cache working as expected but after adding new rendition we found that it was not working.


We need to flush the blob cache using PowerShell.

$webApplication = Get-SPWebApplication "";

After flushing the blob cache we are now able to see newly added rendition. For more details please check

Flush action will not be immediate, it will be queued.

Hope this will help, happy learning.

SharePoint 2013: Identifying the variation source and target with PowerShell

While working with one reporting requirement I needed to eliminate the variation targets and only need to consider variation sources. I struggled to find out the property which will help me to identify the page is variation source or target.


Publishing web and Publishing page have the property called as ‘PublishingPage.Label.IsSource’ which we can use to identify the source page and source web. The same way we can use the publishing web level property as well.

if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($childWeb)){
 $spPubWeb =

 $item = $spPubWeb.PagesList.GetItemById($row.ID);
 $pubPage =

 if($pubPage.VariationPageUrls.Count -eq 0)
     #Page directly created in language sites and not Variated from source
 else #Page Variated
   if($pubPage.Label.IsSource) # then check if the web is Label IsSource
     #this page is variation source

Hope this will help, happy learning.

SharePoint 2013: Make list tools appear again when added multiple web parts on allitems.aspx page

Recently while working with one of the requirement, I needed to add a content editor web part on Allitems.aspx page, I completed the requirement with adding the CE web part on the page but later testing team reported that the top level ‘list tools’ section is not appearing.


After some analysis I found the issue is nothing but default behavior, while allitems.aspx page is unmodified SharePoint knows that list tools section should be shown always and for the same list or library, when we add some other web part like content editor web part the SharePoint actually not able to understand where the focus currently on i.e. on Allitems web part or on the new web part we added.


If customer is fine we can ask customer to click on the List Views web part, then customer will be able to see the list tools directly.

Other solution is to keep the focus on the List Views web part using JavaScript.

<script type="text/javascript">

ExecuteOrDelayUntilScriptLoaded(init_defaultWP, "sp.ribbon.js");

function init_defaultWP() {

setTimeout(function () {

var defaultWP = document.getElementById("MSOZoneCell_WebPartWPQ2");

WpClick({ target: defaultWP, srcElement: defaultWP });

SP.Ribbon.WebPartComponent.$3.deselectWebPartAndZone = function () { };

}, 100);



Happy learning.

SharePoint: Access denied error while calling web service from JavaScript

March 6, 2017 2 comments

Hi Friends,

I would like to share one very specific while calling web service from JavaScript, we were getting exception. Important point to note here is the code is working very fine if we access the page on server. But we are getting JavaScript ‘Error: Access is denied.’ Error while accessing the web page from client machine through browser.


We are getting exception where we are calling the web service.

After some analysis the error came out as HTTP and HTTPS mixed content issue.

In our case HTTPS is configured on load balancer level and on ISS 7 level we have HTTP only hence web service call is working fine.

While accessing from outside URL is getting accessed only with HTTPS and non-secured request is also redirected with secured.

Problem fund that we have used ‘_spPageContextInfo.webAbsoluteUrl’ variable which is providing the HTTP path as SharePoint is unaware with existence of HTTPS as it is configured on load balancer level.

‘_spPageContextInfo.webAbsoluteUrl’ is supposed to give HTTPS path if HTTPS configured on ISS 7 level but as in our case SSL is configured on load balancer hence SharePoint is unaware about SSL.


We have checked the protocol of the browser request using ‘document.location.protocol’ and if it is HTTPS then we replaced HTTP with HTTPS from the output of ‘_spPageContextInfo.webAbsoluteUrl’


This solution is working fine both in the case of HTTPS and HTTP.

Though this scenario is very specific but still this may help someone to understand the issue better.

SharePoint 2013: Modal Dialog position and scrolling issue with lengthy page

We have come across an issue with SharePoint modal dialog, while working with a lengthy page where due to some lengthy content vertical scroll bar were coming. We developed one web part form, which we have added at the center of the vertical screen. From that web part we can open a SharePoint Asset picker to select the image which opens a model dialog. The functionality was working as expected but we found an UI level issues.

Problem: When we try to launch SharePoint ‘Modal Dialog’ from the bottom of the huge scrolled page, we are not able to see the dialog and only see the bluer screen (overlay). The actual model dialog is getting opened at the top of the page and because of the current scroll position which is somewhere in between the screen or at the bottom, we are not able to see the popup.

Solution: The model dialog location is set by CSS class on the top of the screen, we need to override the css class to change the property. The name of the class is ms-dlgContent. We can add following css class in either master page or respective CSS.

position:fixed! important;

SharePoint 2013: Exception while creating default associated groups through PowerShell

While new site collection provisioned default security groups been provisioned when we create it from central administration but not when the site collection was created using script. For that we need to call a function ‘CreateDefaultAssociatedGroups’. This method actually created default associated group example member, Owner and Visitor group and add the group owner as the first parameter provided to the method call.

When I tried it some cases it worked and in some cases I was getting error “Exception calling “CreateDefaultAssociatedGroups” with “3” argument(s): “User cannot be found”

While analyzing the issue the issue I found that I am passing only first mandatory parameter as the user logon name of the group owner. Like –


And then I was getting error Exception calling “CreateDefaultAssociatedGroups” with “3” argument(s): “User cannot be found.” And the default groups are not getting added.

Further analysis concluded that the user I was passing as group owner was not getting added and hence the exception is thrown.

We have used EnsureUser before calling CreateDefaultAssociatedGroups function to make sure that before the call user should be available in user information list like –


SharePoint 2013: Getting lookup column values in JSLink

Hi Friends,

While working on of the development requirement related to JSLink I came across a scenario where a lookup value needed to be shown in a list view web part.

I wanted to demonstrate with following code how we can achieve to show the lookup values form single valued or multi valued lookup.

Before that I would like to show the relationship between the lists I used to show the demonstration.

I have created following two custom lists for demonstration.

First list with following column –



The content in First list will like something –


Second list having lookup column from first list –



The content in second list like following –


Following code will show how to get the single or multi valued lookup values and show.

(function () {

var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.Item = CustomPortalPageItem;
function CustomPortalPageItem(ctx) {
var html = "";
html += '<div title="' + ctx.CurrentItem.Title + '"></div><div>'+GetLookupValues(ctx.CurrentItem.Test11,"lookupValue")+'</div>';
return html;

function GetLookupValues(inputArry,originalColumnName)
var retHtml="";
for(var loopcnt=0;loopcnt<inputArry.length;loopcnt++)
if (typeof(inputArry[loopcnt][originalColumnName]) != 'undefined' && inputArry[loopcnt][originalColumnName] != null)
return retHtml;

After this it will look like following,you can then apply beautiful HTML to it.