Archive

Archive for the ‘MOSS2007’ Category

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.

Solution:

We need to flush the blob cache using PowerShell.

$webApplication = Get-SPWebApplication "http://mytestdomain.com";
[Microsoft.SharePoint.Publishing.PublishingCache]::FlushBlobCache($webApplication);

After flushing the blob cache we are now able to see newly added rendition. For more details please check https://technet.microsoft.com/en-us/library/gg277249.aspx

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

Hope this will help, happy learning.

Advertisements

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.

error1

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.

Solution:

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’

change

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.

Programmatically get the server roles in SharePoint farm

Hi Friends,

While working with Microsoft SharePoint farm we may need to get different server roles it is playing in farm.

Like Application server, Database server, Web Front End server etc.

Following code will show you how we can get the server role using SharePoint object model-

For an example I have created a console application and added reference of ‘Microsoft.SharePoint.dll’ and using

‘Microsoft.SharePoint.Administration’

SPFarm spFarm = SPFarm.Local;
SPServerCollection allServers = spFarm.Servers;
if (allServers != null && allServers.Count > 0)
{
   foreach (SPServer eachServer in allServers)
   {
      switch (eachServer.Role)
      {
	case SPServerRole.WebFrontEnd: Console.WriteLine("WFE:: "+eachServer.Address); break;
	case SPServerRole.Application: Console.WriteLine("APP:: " + eachServer.Address); break;
	case SPServerRole.SingleServer: Console.WriteLine("Single:: " + eachServer.Address); break;
	case SPServerRole.Invalid: Console.WriteLine("Invalid:: " + eachServer.Address); break;
      }
   }
}

Happy coding…

Get all picture libraries in a web

February 14, 2012 Leave a comment

Hi Friends,

While working in MOSS2007 or in SharePoint 2010 we may come across a situation where we need to get all the picture libraries, all task lists or all KPI list and so on.

This is required in many scenarios like in tool part we want a picture library to be displayed in drop down to be given for selection of one picture library.

In following code I am showing two ways using which you can get all picture libraries from a web.

 using (SPSite site = new SPSite(""))
 {
  using (SPWeb web = site.OpenWeb())
  {
     //we will get all lists in this web
     SPListCollection listCollection = web.Lists;

     // first way is to use the GUID for TemplateFeatureId of picture library
     foreach (SPList eachList in listCollection)
     {
         if (eachList.TemplateFeatureId == new Guid
                                        ("00bfea71-52d4-45b3-b544-1c71b620109"))
         {
             ddl.Items.Add(eachList.Title);//here you will get picture libraries
         }
     }

     //second solution will be using the template name
     SPListTemplate Templatetype = SPContext.Current.Web.
                                        ListTemplates["Picture Library"];
     foreach (SPList list in listCollection)
     {
         if (list.BaseTemplate == Templatetype.Type)
         {
             ddl.Items.Add(list.Title);//here you will get picture libraries
         }
     }
  }
 }

Similarly you can use this post http://blogs.technet.com/b/vinitt/archive/2009/11/04/list-of-feature-id-listtemplate.aspx to get the other TemplateFeatureId’s and template name. Using this you can similarly get other types lists also.

After “Export to Excel” button click other click/postback events disabled on SharePoint custom webpart

January 16, 2012 6 comments

While working I came across a difficult situation and not able to found the correct reason behind the issue.

I created a custom web part for MOSS2007 with ASP.net grid view control getting date from list using CAML query and display the data in tabular format. Export to excel functionality required to provide the data in excel to be saved locally from the grid view was one of the requirement I implemented using gridview.RenderControl() method.

I implemented the requirement completely and tested it and as expected it is working perfectly. But if we once clicked the “Export to Excel” button after words other control stops responding like sorting on grid view header, pagination stops posting back on click event.

Then started digging into the issue found the details in one of the telerik grid related post.

Issue is the resubmission of form is stopped by SharePoint to prevent the again and again requesting without the previous request completes. SharePoint maintains a JavaScript flag for this which we need to clear to allow the postback to work after Export to excel.

Solution I used is added following script on the custom web part.Other solutions also available for this problem which explained in  telerik grid related post.

<script type="text/javascript" language="javascript">

//sharepoint postback to work after clicking on export to excel button

if (typeof (_spBodyOnLoadFunctionNames) != 'undefined' &&
                                           _spBodyOnLoadFunctionNames != null)
{
_spBodyOnLoadFunctionNames.push("supressSubmitWraper");

}

function supressSubmitWraper() {

_spSuppressFormOnSubmitWrapper = true;

}

</script>

This view is read-only in SharePoint 2007 datasheet view

November 4, 2011 1 comment

Hi Friends,

While working with Microsoft Office SharePoint server 2007 datasheet view will help end users to add or edit the SharePoint list data using Excel like view.

But some time if you found a message at the bottom of the datasheet view as ‘This view is read-only.’ (As shown in below image) and you are not able to add, delete or update the record using the datasheet view.

To resolve this you need to go to the ‘List setting’ section of that same list and select ‘Versioning Settings’ from General Settings section.(As shown in below image)

Now go to ‘Content Approval’ section and set ‘Require content approval for submitted items?’ to No.(As shown in below image)

Happy coding….