Posts

Token request failed error when getting app only access token

Recently I started seeing token request failed error in my job and my provider hosted app.   The jobs and provided hosted apps have been working well for a long time and it just suddenly happened.  They always failed at TokenHelper.getAppOnlyAccessToken method. Error info: Type: System.Net.WebException Message: Token request failed. After digging around, it looks like there are a few updates on Microsoft to SharePoint, Azure, and AAD.  You can see more details from here, https://techcommunity.microsoft.com/t5/microsoft-sharepoint-blog/provider-hosted-app-pha-application-errors-tls-errors-and-401/ba-p/2273611. Essentially, here are the 2 solution depending where is your code located: If you're running your jobs or web applications on a server, you can apply the change to update the TLS and cipher used.  See the details for the TLS/Cipher changes in the link above. If you're hosting the provided hosted app in Azure web app, you can update your code instead.  You can add ServicePo

Office 365 Delve Blog Monitoring Tool

As my current client is trying to migrate to Office 365 environment from SharePoint 2013 on-premise, one of the issues is controlling the Delve personal blog.  As of now, there is no option to turn off the personal blog creation on Office 365.  So, the client wants to find way to monitor it.  That way they can at least know if there are any content they need to be aware and handled. As you might already aware that there is really no way to do any customization on Delve (at least I can't find any way).  So I couldn't find any way to do any real time monitor with remote event receiver or something like that. However, I did find a way to do a schedule monitor with console application.  After doing some research on google, I found this blog (https://en.share-gate.com/blog/office-365-delve-blogs-explained) that explains how the Delve blog works. In summary, the Delve blog posts are save into a personal site collection in Pages library and they are based on Story Page content (

Add ribbon action and item context menu actions to site content type

Image
I haven't done this for a while and I was searching for it for a while and not getting the correct answer.  So, once I found it, I have to put the information in here just to remind myself later if I have to do it again sometime in the future. Below are functions to add ribbon action and context menu action to Document content type on the site collection level.  The actions requires edit list permission to see. For the ribbon, you'll be passing in the command for the ribbon which looks something like: private static void addRibbonActionToContentType(ClientContext clientContext, ContentType ct, string cmd, string actionName, string actionText)         {             // create the ribbon.             UserCustomAction customAction = clientContext.Site.UserCustomActions.Add();             customAction.Name = actionName;             customAction.Location = "CommandUI.Ribbon.ListView";             customAction.CommandUIExtension = cmd;             customAct

Easy SharePoint custom form

One of my colleges sent me this link which I find it very useful for all SharePoint versions and environment.  Yes, it is working for Office 365 too. All you need is a little bit of JavaScript skills and concept, then you can implement it.  The best part is that you likely won't have to do any update to the script and it'll just work. I know I'm going to refer to it later.  And here is the link. http://www.markrackley.net/2013/08/29/easy-custom-layouts-for-default-sharepoint-forms/

SharePoint 2013 Performance Issue - Very slow when updating Enterprise Keywords field

Our SharePoint 2013 environment was behaving very slowly and one of the WFE utilization is crazy high.  It is particularly obvious when publisher is trying to update the Enterprise Keywords field (Managed Metadata field) for French site. After working with MS on troubleshooting, the root cause is identified as Outdated database statistics. Refer to this article for reference: https://support.microsoft.com/en-us/kb/3103194. Basically, we update the database statistics and remove cache following the article to execute the following. -- Update DB Stats EXEC sp_MSforeachtable 'UPDATE STATISTICS ? WITH FULLSCAN' -- Remove all elements from the plan cache DBCC FREEPROCCACHE This should be part of your DB maintenance on regular basis.

Add spell check dictionary in SharePoint 2010, SharePoint 2013, and Office 365

I was looking for how to add custom spell check dictionary in SharePoint 2013 and I found this blog that describes it, http://softlanding.ca/blog/adding-words-to-the-sharepoint-spell-checker-dictionary-(sharepoint-2013-2010). Here is the summary steps in case the above link doesn't work any more. At the root level of your site create a document library called " Spelling " (make sure to name the document library exactly as listed here) On your desktop create a new text file called " Custom Dictionary ", so that the file name looks like " Custom Dictionary.txt " (make sure to spell the file name exactly as listed here) Open the " Custom Dictionary " text file and in this file type in the words you would like NOT to be considered misspelled words (please note that the words are case sensitive so I would have a separate entry for Softlanding and softlanding, and also please make sure each word is listed on a new line) Upload the " C

SharePoint 2013 REST API Query Items with cross site lookup column

Recently, I had to query items using SharePoint 2013 Rest API (/api/web/lists/getbytitle('')/items).  The problem that makes it hard is that it has a lookup column (Product) that looks up the items in a list from another web.  The typical $filter statement (/_api/web/lists/getbytitle('Pages')/items?$select=Title,Id&$filter=Product eq 1) doesn't work. After searching online and a few trial/error, I got it working by using /_api/web/lists/getbytitle('Pages')/items?$select=Title,Id,ProductId&$filter=Product eq 1 The ProductId field is automatically added to the list by SharePoint when you have a lookup field.  You have to $select that ProductId and then you can filter the Product field.  It's weird but it works.