Monday 28 October 2013

Sharepoint 2010 - "Manage Posts" link in blog site redirects to wrong page

Good Afternoon Friends!

Hope you all are doing good!

We had this requirement from customer to create a blog site with some customizations. For e.g. to add custom Writer field with new post and to display name of that Writer on post instead of default Author field.

For this and some other requirements, we designed a Custom blog site with help of sharepoint designer and created a user solution out of it.

After activation of this user solution on root site collection, we created a custom blog site based on this new blog template. After creation of this new custom blog site, we found a strange issue with "Manage Posts" link on blog site home page. The link was redirecting to the "Category" page instead of redirecting to the actual Post list page.

When I navigated to the "All Site Content" Page then it was looking like this. This might have been the reason for "Manage Posts" wrong redirection.
















Though link to these each above "Posts" were different, it was showing name of every list as "Posts". After struggling a bit for finding the solution for this, We managed somehow to resolve this issue using below steps.  This had something to do with the View of the list.

When navigated to the actual Posts list page(Allposts.aspx) list settings, It was showing the View section as below:


Now we should select any other view (apart from "All Posts") for making it as default, Suppose "My Posts" and make it as default view.



After this again come back to the list settings page, and now select "All Posts" view and now make this view as default. and save.



These steps will now remove all those multiple "Posts" entries from All Site Content page and All site content now will look like this.


If you now check the "Manage Posts" link again on blog home page (which was our primary issue:)), it should now correctly redirect to the desired page i,e. AllPosts.aspx".

Cheers!!

Hope this helps!

Happy Learning!





sharepoint 2010 - modal dialog scrollbar issues

Good Afternoon Friends! :)

Hope you all are doing good!

We faced scroll bar issue in our only blog site for New and Edit Post forms(modal popup). The scroll bars were not at all visible in IE. In chrome and other browsers it was working fine.

This issue caused because of some of our custom master pages. Debugging through the custom master page CSS was cumbersome and fixing issue there might have created some other problems. So we decided on some different workaround.

Any type of list in sharepoint has one option available in ribbon for editing the default New, Edit & Display forms.










- Select Default New(or Edit) Form
- Add one Content Editor webpart on the form
- Select "Edit HTML Source" of the webpart from ribbon
- Add following CSS into the HTML source

<style type="text/css">
BODY #s4-workspace {
OVERFLOW-X: auto !important; OVERFLOW-Y: auto !important
}
BODY #s4-bodyContainer {
HEIGHT: 639px; WIDTH: 619px
}</style> 

- After adding the CSS, Stop editing the page

This CSS will override the default CSS and will eventually shows the scrollbars in modal popup dailog for IE browser.


Hope this helps!

Happy Learning! :)

Sunday 27 October 2013

Sharepoint 2010 - Edit Pagination Size for Blog Commets on Post Details Page

Good Morning Friends! :)

Hope you all are doing good!

Recently we received a request from Customer to update the pagination size of blog Comments webpart in Post.aspx page. (FYI, We only have a single blog site in our intranet) The default pagination size for Comments is 10 and the request from Customer was to make it 50.

The task even though looks simple is not that straightforward to implement. "Comments" webpart view on  post.aspx page is not editable when you edit the webpart. It just shows you the "Current View" in the dropdown list in webpart properties and doesn't provide any link below (like "edit the current view") to edit that view.

When you go to the "Comments" list then you will only find 3 views available inside list settings.
All Comments
My Comments  
By Author

The view which we want to edit is not present there.

So how to do it?

Well, there are couple of options you can try out:
1. Create altogether a new Comments listviewwebpart(or dataviewwebpart) having similar look and feel of the view we want. Only if you have sufficient TIME in hand.
2. Create a new custom view and a new XSLT for showing the desired view. But again time consuming.
3. Use OOB NoteBoard webpart which provides one browsable property for PageSize. But you won't be able to link existing comments to this webpart.
4. Go with powershell script to edit the Comments webpart view pagesize.

I decided to go with the last option (4th one) which was the quickest one. As we only had a single blog site, using powershell script was only the one time activity required on Test and Prod servers.

Powershell script which I have written performs following things:
- Take the reference of the blog site
- Get the reference of "Lists\Posts\Post.aspx" page
- Iterate through Webparts on this page
- Find the Comments webpart for which we want to edit the view
- Fetch the View ID of that webpart by using some string operations
-  Now get the reference of "/Lists/Comments"
- Iterate through all the views of Comments list
- Match the above "View ID" with the desired view we want to edit
- Change the RowLimit property of that view
- Update the view

& You are DONE

---------------------------------------------------------------------------------------------------
Powershell Script
---------------------------------------------------------------------------------------------------

Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.Powershell

$webURL = "{Url for Blog Site Goes Here}"
$web = Get-SPWeb $webURL
$page = $web.GetFile("Lists\Posts\Post.aspx");

$webpartmanager = $web.GetLimitedWebPartManager($page.URL, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

$viewid = ""
foreach($webpart in $webpartmanager.WebParts)
{
if($webpart.Title -eq "Comments")
{
$start = $webpart.XmlDefinition.IndexOf("View Name=");
$end = $webpart.XmlDefinition.IndexOf(" Type=");

$viewid = $webpart.XmlDefinition.Substring(($start + 12), 36)
Write-Host $viewid
#$webpartmanager.SaveChanges($webpart)
break;
}
}

$list = $web.GetList(($web.ServerRelativeUrl + "/Lists/Comments"))
foreach($view in $list.Views)
{
if($viewid -eq $view.ID.ToString())
{
#Write-Host "-------------------"
#Write-Host $view.RowLimit
#Write-Host "-------------------"
$view.RowLimit = 50
$view.Update()
#Write-Host $view.RowLimit
break;
}
}
---------------------------------------------------------------------------------------------------

Hope this helps!

Happy Learning! :)





Thursday 24 October 2013

An administrator must approve this form template before it can be filled out by using browser

Good Afternoon Friends!

Hope you all are doing good!

Here I am sharing steps for resolving issues in Publishing Info Path form.

While working with Infopath 2007, I struggled with this and finally got it working with following steps. 

It goes like this:

If your InfoPath form is having any type of code attached then publishing wizard won't allow you to publish it directly to Sharpoint Site, instead it would require a permission from "Sharepoint Central Administrator" to verify it first and then activate it explicitely on the Sharepoint site. A question can popup in anybody's mind that why it is like this? Answer could be "security measures".

InfoPath Forms attached with unknown code could harm the entire site collection or may be farm so sharepoint provides this authorization mechanism.


Use following guide in sequential order:
(Please note: i worked on following versions: InfoPath 2007, MOSS 2007, WSS 3.0, InfoPath Forms Services) 

A] In InfoPath Designer:

- Allow Full Trust to the form from location “Tools >> Form Options >> Security and Trust”

- Select checkbox “Design a form template that can be opened in a browser or InfoPath” in "Tools >> Form Options >> Compatibility"

B] Publishing the form from InfoPath Designer:

- Screen1 : Select option “To a Sharepoint server with or without InfoPath Forms Services”

- Screen 2:  Enter the location of your Sharepoint or InfoPath Forms Services site

- Screen3: You might notice a help text on the top saying “ An Administrator must approve and blah blah blah”. This help text appears when there is code associated with InfoPath Forms. Just continue by selecting following options from the screen.
-  Select checkbox “Enable the form to be filled out by using a browser” and then select “Administrator approved form template(advanced)”.
- Screen4: Specify a physical location and file name for the form template where you want to store it.

- Screen5: Do nothing and Just click Next

- Screen6: Click Publish

- Screen7: Click Close

You are done with “InfoPath Forms Designer” side.


Now let’s move to “Sharpeoint Central Administration” to approve the published form template by the administrator and Activate it on Site Collection

- Open Sharepoint Central Administration >> Application Management >> In “InfoPath Forms Services” section click “Manage form templates”

- Upload Form Template >> Select the published form template from the physical location used above  (Do not change other default settings on this page) >> Click “Ok”

- In Manage Form Templates list, Right click newly added infopath form template item and activate it to the desired site collection by clicking “Activate to site collection” link. This will activate a feature on site collection level and would add it to the “Form Templates” library. You can check whether the feature is activated by going into that site collection features section and also you can verify whether published template is added to the “Form Templates” library or not.

- Now to add Info path form to webpart, Go to Home page >>> Edit Page >>> Add Page Viewer Web Part >>> Provide url in following format >>> Click Ok >>> Exit Edit Mode

http:// <site name>/_layouts/FormServer.aspx?XsnLocation=http://<site name>/FormServerTemplates/<published InfoPath form template name>.xsn&OpenIn=browser 

That's it!
Now you should be able to see the InfoPath Form contents on your Sharepoint site page.

I hope it helps!

Happy Learning!