Tuesday, July 15, 2014

How to Integrate Twitter with SharePoint to Get Twitter Feeds

Although there are Twitter-SharePoint web parts in codeplex, we can integrate twitter with SharePoint with Out-of-the-box script editor/content editor web parts in few steps.

Simply, follow these steps for adding twitter to SharePoint to get twitter feeds.

Step 1: Go to https://www.twitter.com and Log-in to your Twitter account.(You need to have a twitter account!)

Step 2: Navigate to Settings >> Widgets (https://twitter.com/settings/widgets)
twitter feed web part sharepoint 2010

Step 3: In the widgets tab, Click on "Create New" button
twitter feed in sharepoint 2013

Step 4:  Under "User Timeline" tab, Click on “Create Widget” button to generate Twitter embed code. You can further customize look and feel by following developer API references.
twitter sharepoint 2010 web part

Step 5: Wait for the “Your Widget has been created.” Message from twitter. Now Copy the twitter embed code to clipboard

twitter and sharepoint integration
Here is my twitter widget script generated:
<a class="twitter-timeline"  href="https://twitter.com/SharePointDiary"  data-widget-id="489002092749549570">Tweets by @SharePointDiary</a>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

Step 6: Navigate to your SharePoint site. Add a content Editor web part wherever required (Edit Page >> Add Web Part) . Paste the code copied from twitter into Content Editor’s “Source Editor”, Save and close! This will display twitter feeds in SharePoint sites.

Here is the end Result of Twitter SharePoint integration:
twitter integration sharepoint 2013


The above method works on SharePoint 2007, SharePoint 2010 and even in SharePoint 2013! compared with methods to show twitter RSS feed using XML Web parts, XSL in SharePoint, I consider the above method is relatively simple!
adding twitter to sharepoint 2007



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Five Challenges in SharePoint Security
...And How to Solve Them. Free White Paper
*Sponsored


Thursday, July 10, 2014

Download All Document Versions using Web Services - PowerShell

Requirement:
Wanted to extract and download each version of the document stored in a SharePoint library. Well, PowerShell can do it from client side using web services. Here is the PowerShell script to download each version to the local folder programmatically.
# ******* Variables Section ******************
#Define these variables 
$WebURL="http://sharepoint.crescent.com/sites/Operations/"
$FilePath ="http://sharepoint.crescent.com/sites/Operations/docs/designDoc.docx"
$TargetFolder = "C:\Downloads"
# *********************************************

#Web Service URL
$WebServiceURL =$WebURL+"_vti_bin/Versions.asmx"
$WebService = New-WebServiceProxy -Uri $WebServiceURL -UseDefaultCredential
$WebService.URL=$WebServiceURL

#Get File name from file path
$FileName = $FilePath.Substring($FilePath.LastIndexOf("/")+1,($FilePath.Length-$FilePath.LastIndexOf("/")-1))

#Create the Target Library if it doesn't exists
    if (!(Test-Path -path $TargetFolder))
       {   
             #If it doesn't exists, Create
             $TargetFolder = New-Item $TargetFolder -type directory
       }


#Call web service method "GetVersions" to retrieve versions collection
$FileVersions = $WebService.GetVersions($FilePath).Result
 foreach($File in $FileVersions)
 { 
  #Frame the File name : E.g. 1.0_Filename.ext
  $VersionFileName = "$($TargetFolder)\$($File.version)_$($FileName)"
  write-host $VersionFileName
  $webclient = New-Object System.Net.WebClient
     $webclient.UseDefaultCredentials = $true
  write-host $File.url
     $webclient.DownloadFile($File.url,$VersionFileName)
  Write-Host "Downloaded version: $($File.Version)"
 }


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Five Challenges in SharePoint Security
...And How to Solve Them. Free White Paper
*Sponsored


Expand-Collapse All Groups in SharePoint 2013 List Views using jQuery

SharePoint doesn't has the ability to expand/collapse all groups in grouped list views. However, with jQuery we can bring Expand All-Collapse All buttons in SharePoint 2013 grouped list views. Just edit the grouped view page (Site Actions Gear >> Edit Page), add a "Script Editor" Web part and then place the below code in it.

jQuery for Expand-Collapse all items in grouped views in SharePoint 2013:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.2.6.min.js"></script>

<script type="text/javascript">
  
    function expandAll() {
        $("img.ms-commentexpand-icon").click();
    }

    function collapseAll() {
        $("img.ms-commentcollapse-icon").click();
    }

    var expandButton = "<a href='#' onClick="

    +'"' + "this.href='javascript:expandAll()'"

    + '">&nbsp;<img title="expand all groups" style="border:none;" alt="expand all" src="/_layouts/images/collapseplus.gif"></a>';

    var collapseButton = "<a href='#' onClick="

    +'"' + "this.href='javascript:collapseAll()'"

    + '">&nbsp;<img title="expand all groups" style="border:none;" alt="collapse all" src="/_layouts/images/collapseminus.gif"></a>';

    $(document).ready(function () {
        $(".ms-pivotControl-container").append(expandButton).append(collapseButton);
    });
</script>
and here is the result:
Thanks to: https://www.nothingbutsharepoint.com/sites/eusp/pages/jquery-for-everyone-expandcollapse-all-groups.aspx for the idea!

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Five Challenges in SharePoint Security
...And How to Solve Them. Free White Paper
*Sponsored


Tuesday, July 8, 2014

How to Change Logo in SharePoint 2013

As a branding initiative, The first thing people do to customize SharePoint site is: changing logos to their company logo. Here is how to change logo in SharePoint 2013:
  1. Navigate to the Site Settings Page by clicking "Site Settings" link from settings gear.
    sharepoint site logo change
  2. Under the "Look and Feel" section, click on "Title, description, and icon" link. 
    sharepoint 2013 custom logo
  3. Select the logo either from your computer ( When insert from computer, the logo will be upload to "Site Assets" library.) or from any SharePoint library.
    sharepoint 2013 insert logo from computer
  4. Optionally, You can enter Logo description. Click OK to apply your new logo. You can copy the logo file to your each WFE, so that the logo will be retrieved from file system rather from a SharePoint library of a site collection
and the result of SharePoint 2013 change logo URL:
sharepoint 2010 add logo to site
Tips: Keep the logo background transparent so that it can match on any color theme!
That's all!

FAQS on SharePoint Logo:


SharePoint 2010 logo change
The same procedure applies to SharePoint 2010 also to set site logo.
sharepoint 2010 change logo

SharePoint 2013 change site logo programmatically
You can set: SiteLogoUrl property of the SPWeb Object to change site logo programmatically in SharePoint. Here is how:
SPSite.RootWeb.SiteLogoUrl = "Logo-URL"; //such as:"/_layouts/15/images/CustomLogo.png" or "/sites/operations/siteassets/CustomLogo.png"
We are setting the Root Web's logo property to inherit site logo on all of its sub sites.

SharePoint 2010/2013 change logo for all sites
Out-of-the-box there is no shortcut, But these tricks will do: SharePoint 2013 default site logo URL is: "/_layouts/15/images/siteIcon.png", for SharePoint 2010, SharePoint 2013 logo location at: "/_layouts/images/siteIcon.png". The "Images" folder is a virtual folder mapped to "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\IMAGES" in the SharePoint web front end servers.
sharepoint 2013 logo location
So, the trick is: Take a backup of the logo file "SiteIcon.png" and replace your logo with the same name! Much cleaner approach will be: Set logo using PowerShell.


Set SharePoint 2010 Logo URL using PowerShell
Lets change logo for all sites in the entire farm - which includes all sub-sites from all web applications.
Get-SPWebApplication | Get-SPSite | Get-SPWeb |  foreach { " Changing Logo for:" $_.Url; $_.SiteLogoUrl="/_layouts/images/your-logo.png" }
Read more at: SharePoint 2013 Change Site Logo Programmatically with PowerShell

SharePoint 2010 add logo to feature:
You can pack and deploy your custom logo as part of SharePoint solution package.

I changed the logo, but still getting the old logo. This could be because of the browser cache. Try hitting Control+F5 keys. Quick fix: Change the logo image file name in 12/14/15 hive and run the PowerShell code to apply new logo image!

Getting repeated authentication prompt after changing logo: Your logo file in 15 hive or library is not inheriting permissions. Go to the properties of the file and inherit permissions to fix this issue. This could also happens when Logo file is stored in SharePoint libraries - Make sure users have read access at least! and it should be approved (if content approvals is enabled!), checked-in and published!

Web part Pages doesn't display New Logo:
Well, its a known issue and find the solution at: Fix Custom SharePoint 2010 Logo Missing in Web Part Pages

SharePoint 2010 logo not displaying
SharePoint site logo not displaying, instead it gives red x in the place of logo. This happens when SharePoint site logo path is not valid!  Right click on the broken site logo image, Copy-Paste the URL of the image, verify that the logo path is correct.
sharepoint 2013 logo not displaying red x

Make SharePoint 2010 logo link root site
By default, on clicking the site logo, it takes us to the root of the current site. Its possible to change the logo hyperlink. Here is how: Make SharePoint Site Logo Link Point to Root Site Collection

SharePoint 2010 master page logo
You can change logo from SharePoint 2013 master page level also. Locate the element: <SharePoint:SiteLogoImage> and you can change the Logo Image URL attribute of it.

 SharePoint2013 hide logo
To remove logo from SharePoint 2013 sites, we can make it hidden with this style:
.s4-titlelogo > a > img{
visibility: hidden;
}
To remove any custom logo, simply clear the logo URL already set!

SharePoint logo size
The default size of the SharePoint 2013 logo is: 180x64 pixels. But SharePoint 2013 changes this size according to your logo size. To increase logo size simply resize your SharePoint 2013 logo with Photoshop or any other relevant tool. To change logo size (width and height) in CSS, use this styles:
.s4-titlelogo > img, .s4-titlelogo > a > img { width: 150px;height: 150px;}


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Five Challenges in SharePoint Security
...And How to Solve Them. Free White Paper
*Sponsored


Wednesday, June 25, 2014

Nintex Workflow Timeout Issue - Solutions

Recently got these timeout related errors in Nintex workflow 2007 with MOSS 2007 environment:
  • "Failed to report workflow progress. Failed to open a connection to a Nintex Workflow content database"
  • "Failed to Start Workflow. Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding"
  • Error: Timeout expired. The timeout period elapsed prior to completion of the server is not responding
Here is some error screenshots:
Failed to report workflow progress. Failed to open a connection to a Nintex Workflow content database
 and the another one:
Failed to Start Workflow. Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding
Meanwhile, In Event Logs, Found these errors:
Nintex Workflow; Build: 11201 (http://sharepoint.crescent.com/finance/approvals/default.aspx)
System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader()
   at Nintex.Workflow.Reports.MyWorkflowInfoCollection.BuildCollection(String username, SPWeb web, Int32 minRow, Int32 maxRow, String orderBy, OrderByDirection direction, List`1 statesToShow)
   at Nintex.Workflow.Reports.MyWorkflowInfoCollection..ctor(String user, SPWeb web, Int32 minRow, Int32 maxRow, String orderBy, OrderByDirection orderByDirection, List`1 statesToShow, Boolean& additionalRows)
   at Nintex.Workflow.ServerControls.WebParts.MyWorkflows.LoadView()
   at Nintex.Workflow.ServerControls.WebParts.MyWorkflows.Render(HtmlTextWriter writer)

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

Troubleshooting Steps:

Verify database is up and running and there is no network connectivity issues between Web and Database Severs. Follow these steps to troubleshoot timeout issues.

1. Increase Timeout value: 
Get the current database connection timeout value by:
stsadm -o getproperty -pn database-connection-timeout

By default, it would be 15 seconds. You can increase the timeout with the below command:
stsadm -o setproperty -pn database-connection-timeout -pv 60
This can be used for SharePoint Database connectivity Timeout Issues too.

2. Workflow Content Database may grown to large in size:
Large amount of data in the Nintex content database tables could likely to cause SQL Server timeout errors. So, Analyze Nintex content database table sizes. Here is how to do it in SQL Server 2008 and above.
  1. Open SQL Management Studio >> Expand the Database node
  2. Find the Nintex Workflow database (usually named NW2007DB or NW2010DB)
  3. Right-click on the Nintex Workflow database and select Reports > Standard Reports > Disk Usage by Table
If you are running with SQL Server 2005, use the below query to analyze database table usages:
USE [Nintex_WF_2007_Content]
begin try 
SELECT 
 a3.name AS [schemaname],
 a2.name AS [tablename],
 a1.rows as row_count,
 (a1.reserved + ISNULL(a4.reserved,0))* 8 AS reserved, 
 a1.data * 8 AS data,
 (CASE WHEN (a1.used + ISNULL(a4.used,0)) > a1.data THEN 
   (a1.used + ISNULL(a4.used,0)) - a1.data ELSE 0 END) * 8 AS index_size,
 (CASE WHEN (a1.reserved + ISNULL(a4.reserved,0)) > a1.used THEN 
   (a1.reserved + ISNULL(a4.reserved,0)) - a1.used ELSE 0 END) * 8 AS unused
FROM
 (SELECT 
  ps.object_id,
  SUM (
   CASE
    WHEN (ps.index_id < 2) THEN row_count
    ELSE 0
   END
   ) AS [rows],
  SUM (ps.reserved_page_count) AS reserved,
  SUM (
   CASE
     WHEN (ps.index_id < 2) THEN 
   (ps.in_row_data_page_count + ps.lob_used_page_count + ps.row_overflow_used_page_count)
     ELSE (ps.lob_used_page_count + ps.row_overflow_used_page_count)
   END
   ) AS data,
  SUM (ps.used_page_count) AS used
 FROM sys.dm_db_partition_stats ps
 GROUP BY ps.object_id) AS a1
LEFT OUTER JOIN 
 (SELECT 
  it.parent_id,
  SUM(ps.reserved_page_count) AS reserved,
  SUM(ps.used_page_count) AS used
  FROM sys.dm_db_partition_stats ps
  INNER JOIN sys.internal_tables it ON (it.object_id = ps.object_id)
  WHERE it.internal_type IN (202,204)
  GROUP BY it.parent_id) AS a4 ON (a4.parent_id = a1.object_id)
INNER JOIN sys.all_objects a2  ON ( a1.object_id = a2.object_id ) 
INNER JOIN sys.schemas a3 ON (a2.schema_id = a3.schema_id)
WHERE a2.type <> 'S' and a2.type <> 'IT'
ORDER BY a3.name, a2.name
end try 
begin catch 
select 
        ERROR_NUMBER() as tablename
,       ERROR_SEVERITY() as row_count
,       ERROR_STATE() as reserved
,       ERROR_MESSAGE() as data
,       1 as index_size
,   1 as unused 
end catch
Make sure: dbo.WorkflowProgress table down to about 10-15 million rows!

What to do when Workflow Progress table is over sized?
You can reduce the size of the workflow progress database table: http://connect.nintex.com/files/folders/white_papers/entry30032.aspx

Find Which Workflows Causing this bottleneck: 
Lets find which workflows are flooding the database tables. Use the below query to find all Nintex workflows (such as: Popular workflows or errored workflows) which may over utilize workflow progress table.
SELECT TOP 100 
I.WorkflowName, 
I.WorkflowInstanceID, 
I.SiteID, 
I.WebID, 
I.ListID, 
I.ItemID, 
I.WorkflowInitiator, 
I.WorkflowID,
I.State, COUNT(P.WorkflowProgressID) as WorkflowProgressRecords
FROM WorkflowInstance I inner join WorkflowProgress P WITH (NOLOCK)
ON I.InstanceID = P.InstanceID
--WHERE i.State=2 
GROUP BY I.WorkflowName, I.WorkflowInstanceID, I.SiteID, I.WebID, I.ListID, I.ItemID, I.WorkflowInitiator, I.WorkflowID, I.State 
ORDER BY COUNT(P.WorkflowProgressID) DESC
Here is the output:

From the above data, Use: Get SharePoint Site Collection, Web, List Objects from GUID to get the list/web/site objects.

Purge Workflow Data:
So, We got which workflow instances are causing this bottle neck. Next step is to Purge workflow data! Lets Purge workflow data using Nintex Admin command line tool: NWAdmin.exe (Located at: C:\Program Files (x86)\Nintex\Nintex Workflow 2007)

NWAdmin.exe -o PurgeWorkflowData -instanceId "GUID of the workflow instance"

Also, You can try purging workflow data based on date, Workflow status, etc. Keep an eye on the workflow content database, Log file sizes. Try truncating log files.

3. Move Workflow data to Another Workflow Content database:
You can also move workflow data to a new workflow content database. Follow these steps:
http://connect.nintex.com/files/folders/30882/download.aspx

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Five Challenges in SharePoint Security
...And How to Solve Them. Free White Paper
*Sponsored


You might also like:

Related Posts Plugin for WordPress, Blogger...