Archive

Posts Tagged ‘Sharepoint2010’

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.

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.

Solution:

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 =
 [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($childWeb);

 $item = $spPubWeb.PagesList.GetItemById($row.ID);
 $pubPage =
 [Microsoft.SharePoint.Publishing.PublishingPage]::GetPublishingPage($item);

 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: 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.

SharePoint: Using Papercut for testing the email functionality in SharePoint.

October 31, 2014 Leave a comment

In many scenarios while working with SharePoint we may come across requirement to test emails. Like email alerts, emails from workflow, timer jobs or event receivers etc. In my case I need to test emails from Timer job.
While development phase it is not always possible to have a SMTP sever available to test those kind of functionality and in those scenarios Papercut is best utility available for our help. Papercut is a simplified SMTP server designed to only receive messages and serve the purpose of light weight SMTP.
You can use Papercut in .Net development or SharePoint development. You just need to download and install the Papercut on your SharePoint server.

Papercut-v3.1.0-S1
Some points to consider while using Papercut with SharePoint-
1. Papercut is only to receive emails.
2. In case of ASP.Net application provide host=”127.0.0.1″ port=”25″ in web.config file under mailsettings section.
3. For SharePoint, If you have single server farm then you don’t need to worry just install Papercut and set the ‘Outbound SMTP Server’ to localhost or 127.0.0.1 in ‘Configure outgoing e-mail settings’ under central admin, System settings.
4. You can now test by creating simple alert on any list.
5. If you have muti-server farm and testing email from timer job then need to find on which server timer service is running and on that sever you need to install Papercut also give this server IP in ‘Outbound SMTP Server’ in ‘Configure outgoing e-mail settings’ under central admin, System settings.
6. If timer service running on more than one server then make sure port 25 open between those servers to get emails from timer job.
Hope this will help.

Note: complete contribution, development and license rights are with the team who have developed this and as per the http://papercut.codeplex.com/license . This post is just to make readers aware that this kind of tool exists.

Setting ‘Show field’ for “Person or Group” type column using PowerShell

October 10, 2013 4 comments

Hi Friends,

While fixing one issue I needed to change the ‘Show field’ setting for “Person or Group” type of column like Modified By column, My first thought is to use ‘ShowField’ property of a column as I seen this property exist in <Field XML.

Bellow image shows the “show field” option on Edit column page.

Show_Field

I tried multiple option with ‘ShowField’ but no luck and the property was not changing, then after debugging the issue I found that we need to use column’s “LookupField” property to change the setting like following.


Add-PSSnapin Microsoft.SharePoint.PowerShell
$webURL = "<Your web url>";
$web = Get-SPWeb $webURL;
$mylistName = "<Your list name>";
$mylist = $web.Lists[$mylistName];
$mycolumn = $mylist.Fields["Modified By"];
$mycolumn.LookupField = "Title";
$mycolumn.Update();
$mylist.Update();

The other available options to set the ShowField are as following table-

Sr.No. Show Field drop down options Exact value need to pass LookupField property
1 Name Title
2 Account Name
3 Work email EMail
4 Mobile phone MobilePhone
5 SIP Address SipAddress
6 Department Department
7 Title JobTitle
8 First name FirstName
9 Last name LastName
10 Work phone WorkPhone
11 User name UserName
12 Office Office
13 ID ID
14 Modified Modified
15 Created Created
16 Name (with presence) ImnName
17 Picture Only (36×36) PictureOnly_Size_36px
18 Picture Only (48×48) PictureOnly_Size_48px
19 Picture Only (72×72) PictureOnly_Size_72px
20 Name (with picture and details) NameWithPictureAndDetails
21 Content Type ContentTypeDisp

Hope this will help someone from developer community.

SharePoint: issue with $top in ListData.svc

September 10, 2013 2 comments

Hi Friends,

While working on SharePoint REST API’s in SP 2013 I come across a scenario where I need to filter on date column, I found solution to use /_vti_bin/ListData.svc service to filter based on date column like following, we can’t use RESTful call in date filtering –

var date = new Date();

var stringUrl=_spPageContextInfo.webAbsoluteUrl+"/_vti_bin/ListData.svc/EventsCalendar?$filter=StartTime+ge+datetime'"+date.toISOString()+"'&$select=Title,Description,Path,Id,StartTime&$orderby=StartTime&$top=3";

When I tried this I was getting data in browser but not using JavaScript code which is using $.ajax call to get and read the response.

After analyzing I found that $top is the culprit in my case and found following workaround.

When we use $top we will get the result date in ‘data.d’ like following-

var resultsArray = data.d;

If you want old JS code ‘data.d.results’ to work as is with $top we need to use $inlinecount=allpages in URL call like following

var date = new Date();

var stringUrl=_spPageContextInfo.webAbsoluteUrl+"/_vti_bin/ListData.svc/EventsCalendar?$filter=StartTime+ge+datetime'"+date.toISOString()+"'&$select=Title,Description,Path,Id,StartTime&$orderby=StartTime&$top=3&$inlinecount=allpages";

Happy coding….

Easiest way to get SharePoint feature id from user interface

February 26, 2013 3 comments

Hi Friends,

After a long I got some time to write post.

While working with SharePoint many times we need to get the feature ID of custom or out of box feature.

Example if I want to activate or de-activate the feature or for other purpose.

Basically what we need  to complete this operation, we need ID of the feature to complete the activation or de-activation operation in PowerShell.

So what is the easiest way to get the feature ID.

We can use the same ManageFeatures.aspx page using which we can activate or de-activate the feature ID and developer tool of browser.

  1. Go to Manage Site Feature page
  2. Use F12 to enable developer tool of browser(either IE web developer or Firebug)
  3. Select the Activate button of the feature whose ID you wanted to know.
  4. Check immediate parent div in developer tool, it will have an id attribute which is nothing but ID of respective feature.

Image

Hope this will help you to save some of your time.