Showing posts from 2013

Custom action to a callout in SharePoint 2013

During my POC, I was trying to add custom action to a callout same like, Share and follow. found easy way to do it with following script. SP.SOD.executeFunc("callout.js", "Callout", function () { var itemCtx = {}; itemCtx.Templates = {}; itemCtx.BaseViewID = 'Callout'; // Define the list template type itemCtx.ListTemplateType = 101; itemCtx.Templates.Footer = function (itemCtx) { return CalloutRenderFooterTemplate(itemCtx, AddCustomAction, true); }; SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx); }); function AddCustomAction (renderCtx, calloutActionMenu) { // Add custom action calloutActionMenu.addAction (new CalloutAction ({ text: "Custom Action", tooltip: 'This is your custom action', onClickCallback: function() { console.log('Alert from custom action'); } })); } We are good to go!!

PowerShell to Cancel All SharePoint Workflows in Progress

I was struck with requirement were having big list and workflow attached to it, need to cancel all running workflows.  It could be either manually traverse all the way and stop it, was next to impossible. Following script helped me to save my time! $web = Get-SPWeb ""; $web.AllowUnsafeUpdates = $true; $list = $web.Lists["CustomListName"]; $count = 0 foreach ($listItem in $list.Items) { foreach ($workflow in $listItem.Workflows) { if(($listItem.Workflows | where {$_.InternalState -ne "Completed"}) -ne $null) { #Cancel Workflows [Microsoft.SharePoint.Workflow.SPWorkflowManager]:: CancelWorkflow($workflow); write-output "Workflow cancelled for : " $listItem.Title; } } } $web.Dispose(); Hope this will save your time!

SP2013 : Task list not visible to other users

I came across weird issue, I created a task list with the system account. This list is not able to view by any other users. Spent enough time on finding a cause. It was all due to IE, it was working fine with Chrome and other browsers. To make it work with IE: 1.  Active x and JS permissions has to be enabled. 2.  The site has to be in the trusted pool of you internet explorer.   3. D isable any extra add-o ns. Hope this small piece of information will save time

Create a custom view on Workflow Task Status

I came across to the requirement to create a custom view based on workflow status. Requirement was to show all the approved items. I found a interesting stuff, Filter will not work if we use words like below image: we would need use the number rather than the words (e.g. 2 instead of In Progress, 4 instead of Cancelled etc) Following list might help for this kind of requirement: Status Value Not Started 0 Failed on Start 1 In Progress 2 Error Occurred 3 Canceled 4 Completed 5 Failed on Start (retrying) 6 Error Occurred (retrying) 7 Canceled 15 Approved 16 Rejected 17 Hope this will save your time!

Provider Hosted App - Azure and Read, Write to SharePoint List with real example

Hi, After my first blog on simple app, Now will go in detail about how to read and write SharePoint list with Provider Hosted App. Here to cover all the scenario implementing it with real example by creatingvTrello App. is basically a task management tool. I am developing app which will have following functionality, 1. App will take user token (oauth) from Trello to read all the cards  for current logged in user. 2. Trello will return token, which our app will store in one SharePoint list so next time when user visit the app, will get the token from list and directly get all the cards from trello. Now, lets start and build this app. 1. Having Default.aspx in my solution, adding following code in page_load to get the access token public partial class Default : System.Web.UI.Page { public static string userToken = string.Empty; Uri appWeb; string myAccess

Step By Step- SharePoint 2013 Provider Hosted App - Azure Hosting

Here In this blog on SharePoint 2013 Provider hosted app will try to cover each and every steps to create provider hosted app. 1. Open Visual Studio 2012. 2. Click on New Project -> Select SharePoint template  3. Visual studio will prompt to add Office 365 SharePoint Site you are using and select the Provider-hosted from dropdown list. 4.  On selection of Provide Hosted, click Next you will be prompted with following screen. Select use a client secret option. 5. Now, Click on Finish. visual studio will take some time to prepare solution. 6. Solution has been created with two projects, looks like below image, 7.   App project will be deployed to SharePoint. And  AppWeb project will  be .Net Web Application.  8. Now lets Deploy Provider-Hosted App to SharePoint.  here, I am adding some sample test text in default.aspx as per below code, <html xmlns="" > <head runat="server"&

Error: Web deployment task failed. .. User_UNAUTHORIZED - Provider Hosted App

During development of provider hosted app, while deployment I was greeted with error : Web deployment task failed. (Connected to the remote computer ("") using the Web Management Service, but could not authorize. Make sure that you are using the correct user name and password, that the site you are connecting to exists, and that the credentials represent a user who has permissions to access the site.  Learn more at: After some research came to know need to download the Publish Profile from site and attached new publish profile, helps me to solve this issue. It was due to changes in site happens are not detected in old publish profile, which leads to this error. Hope this fix will save you time!

The option for the SharePoint 2013 workflow platform is not available because the workflow service is not configured on the server

Hi there, I have configured SharePoint 2013 and Workflow Manager. Created new Site Collection. However I was not able to create SharePoint 2013 workflows. Option for"SharePoint 2013 Workflow" (but SharePoint 2010 workflows works). Issue was, The site collection was created using blank template, which doesn't include all necessary dependency features for creating workflows. Fix: we need to enable hidden feature WorkflowServiceStore using PowerShell. Enable-SPFeature -Identity WorkflowServiceStore –Url $yourUrl And finally I got option in SharePoint Designer:

The parameter 'token' cannot be a null or empty string - Provider Hosted App SharePoint 2013

Hi, Today while my research on SharePoint Provider hosted app with Azure, after deployment I was greeted with "The parameter 'token' cannot be a null or empty string ". I was almost crazy behind finding the cause. However finally I found some points which leads me to resolve this error. The ClientID in your AppManifest.xml and in your Web.Config should be same. In AppManifest.xml file domain reference to Azure should be HTTPS rather than HTTP. Should have proper permission on web,list,site collection according to your app.    Happy coding!

The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information, contact your server administrator

Hi there, I was having a requirement to create SharePoint 2013 approval workflow using 2010 template. workflow was attached to content type. Issue I was facing, while going to start the workflow it gives error of " The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information, contact your server administrator" After some research came to find the solution,  this is related to state service as mentioned in error above. Paste following commands in SharePoint management shell: $serviceApp = New-SPStateServiceApplication -Name "State Service" New-SPStateServiceDatabase -Name "StateServiceDatabase" -ServiceApplication $serviceApp New-SPStateServiceApplicationProxy -Name "State Service" -ServiceApplication $serviceApp -DefaultProxyGroup And now again I tried to start the workflow, and it started successfully!

SharePoint 2013 Workflow error : Custom outcome column returns default option as a task result

I was facing weird issue in SharePoint 2013 Designer workflow. Scenario was, I wanted to create one list workflow where custom list was created programmatically and having my custom workflow task list created through code as well custom content type and outcome columns also created programmatically. Now in workflow stage having an Assign task action and in Outcome options using the above created content type and site columns, see the figure below: Issue here I was facing, Task result was always showing "TaskOutcome:0" i.e the default Outcome in task inspite of I selected any another option. example in above figure result was always coming "Action Plan Created". Tried different approaches to make it work: -While debugging tried various options to make it work, like installed update where it mentioned that "Assume that you use non-ASCII characters to name a task outcome field in a task in a custom workflow.

Errors were found when compiling the workflow. The workflow files were saved but cannot run. - SharePoint 2013

Today while trying to publish the workflow, came across the weird error "Errors were found when compiling the workflow. The workflow files were saved but cannot run." After digging into it, came to the solution that need to    Re-register service into my site using   following commands: Register-SPWorkflowService -SPSite 'https://my-host/mysite' -WorkflowHostUri 'https://workflowhost' -AllowOAuthHttp -Force I reopened SharePoint Designer again and problem disappeared. Hope this will save your time.

Powershell To Attach workflow on Content Type and create Retention Policy on it - SharePoint 2013

Hi Friends, I got a requirement to create retention policy on Content type and action is to start workflow. as well attach workflow to the content type. I choose to go with powershell. save the following code into file called SetupRetentionPolicy.ps1 call like: c:\>.\SetupRetentionPolicy.ps1 -url <weburl> -ContentTypeName <Contenttype> param( $url=$null, $ContentTypeName=$null) $site = get-spsite $url $web = $site.openweb() Enable-SPFeature –identity "LocationBasedPolicy" -URL $url -ErrorAction SilentlyContinue $Property = "Modified" $Period = 1; $PeriodType = "years" function AddWorkflowToContentType($site, $ctName, $WfName, $WfAssociationName, $TaxTaskList) { [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SharePoint') [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.Office.Policy') [Guid]$wfTemplateId = New-Object Gui

How to: Follow documents and sites by using the .NET JavaScript object model in SharePoint 2013

Scenario is here we will create one sample user control, which will have simple one star which we can place on our page to follow the site/documents using JavaScript object model. 1. Visual Studio 2012, SharePoint project. 2. Add new item, web user control and give a name : favoriteControl.ascx 3. <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FavoriteControl.ascx.cs" Inherits="test.FavoriteControl" %> <div class="favIcon" runat="server" id="favoriteLink"><a href="#" runat="server" id="favorite" onclick="javascript:Follow();"></a></div> 4. Add Script file to project, named favoritehelper.js and paste the following code: $(document).ready(function () { // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs. //SP.SOD.executeOrDelayUntilScriptLoaded(loadUserData, 'sp.userprofiles

SharePoint 2013 Workflow gets canceled automatically

Hi, I was struck with the error of Workflow gets canceled automatically. Scenario was : A new SP 2013 installation, one server with SP, WF, etc and the other is simply SQL Server. Went through the installation steps for Workflow including the powershell bits. In designer, I am able to create a simple workflow and select 2013 as the type. When the workflow is run, is shows internal status is canceled and has the following error text below. RequestorId: 55c6990b-c4a6-352c-4a5b-449fc1aecac4. Details: System.ApplicationException: HTTP 401 {"x-ms-diagnostics":["3001000;reason=\"There has been an error authenticating the request.\";category=\"invalid_client\""],"SPRequestGuid":["55c6990b-c4a6-352c-4a5b-449fc1aecac4"],"request-id":["55c6990b-c4a6-352c-4a5b-449fc1aecac4"],"X-FRAME-OPTIONS":["SAMEORIGIN"],"SPRequestDuration":["61"],"SPIisLatency":["1&

SharePoint 2013 Taxonomy import using .csv and Setting site navigation to use taxonomy using PowerShell

Now requirement to import taxonomy from .csv file using PowerShell as well set taxonomy as site navigation with url. 1. Create .csv file 2. Create new script and paste below code. Param( [string] $siteUrl = $(throw "Error: Parameter siteUrl is required"), [boolean]$emptyfirst ) ##Variables that should not be edited $termsetName="My Navigation" function CreateTerm( $parent, $name, $url ) { Write-Host "Adding term $($parent.Name) -> $name" $term = $parent.CreateTerm("$name", 1033) $term.IsAvailableForTagging = $false $term.SetLocalCustomProperty("_Sys_Nav_ExcludedProviders", '"CurrentNavigationTaxonomyProvider"') $term.SetLocalCustomProperty("_Sys_Nav_SimpleLinkUrl", $url) #$term.SetLocalCustomProperty("tIME", $url) return $term } function GetTerm($termName, $parent) { $termName = [Microsoft.SharePoint.Taxonomy.TaxonomyI

SharePoint 2013 TermSet with PowerShell

Create new script with following code: $session = Get - SPTaxonomySession - Site "Your site Url" $termStore = $session . TermStores [“ Managed Metadata Application ”] - change your managed metadata service name $group = $termstore . CreateGroup (“ My New Group ”) $group . Description = "My Term Group" $termStore . CommitAll () $termSet = $group . CreateTermSet (“ My TermSet ”, 1033 ) $termSet . Description = “ My TermSet ” $termSet . IsAvailableForTagging = $true $termSet . IsOpenForTermCreation = $true $termStore . CommitAll () To enable the term set for navigation, i.e    "Use this Term Set for Site Navigation"   use following code to make it enabled. $navigationSet = $group . CreateTermSet ( $termsetName ) $navigationSet . SetCustomProperty ( "_Sys_Nav_IsNavigationTermSet" , "True" ) $navigationSet . SetCustomProperty ( "_Sys_Nav_AttachedWeb_SiteId" , $site . ID . ToString