Some thoughts on programming stuff

Category: Troubleshooting

Edit Rendition invisible in the Ribbon

If you happen to have the Edit Rendition invisible in the Ribbon in SharePoint and you did everything right when setting up the environment and enabling Blob Cache in your SharePoint site. Don’t worry, this blog post will help you with simple trick!

Image renditions are great when you want to provide content in different screens using specific dimensions to help people crop the image or focus in what matters most when presenting it. It’s not common to have problems with them as they add great value to your solution.

Complementing, Microsoft documentation says: “Image renditions enable you to render a single image in multiple ways. An image can be displayed in various sizes or with different cropping. The first time that an image is requested, SharePoint Server uses the specified image rendition to generate the image. When a user views a SharePoint site, the correctly sized version of the image is downloaded to the client computer. This reduces the size of the file that is downloaded to the client, which improves site performance. “.

Edit Rendition invisible in the Ribbon - Button invisible
Edit Renditions button not showing
Continue reading

Force Flush Blob Cache in SharePoint

If you need to force flush blob cache in SharePoint, this script is for you! It will ensure that every file once cache will be deleted and will force SharePoint on recreating it when it sometimes becomes corrupt.

After running this script, you will get back on track and the cache will be flushed. But be cautious! This script will only affect the server where it’s being executed. In cases where you have multiple web application servers working together, the script must be executed in each server. It is necessary because each server holds its personal folder where the assets will be stored and cached.

The Blob Cache is an important feature that must be used when you have heavy traffic with lots of anonymous users, or even if you need to explore Image Renditions (we have a blog post about some problems there too). You can find over the internet a lot of content about it, but I must say that exists some undocumented stuff about the topic that may have been lost in the history and it’s just present in some old books about SharePoint.

The Script to force flush Blob Cache

All the steps below are important to get things working again. Basically our script will delete the Folder where you have configured the Blob Cache to store the files, then we will call the Flush Blob Cache method offered by the SPWebApplication object from SharePoint. Finally, the iisreset is an important step because it will ensure that the everything is rewinded and refreshed.

That’s it! I hope this script can help you getting things on track, perfoming a force Flush Blob Cache in SharePoint and serving a good SharePoint Site with awesome performance to your users.

References:
Karine Bosch blog;
Microsoft documentation.

Image Renditions throwing error in SharePoint

If you use the Image Renditions feature in SharePoint, sometimes it can throw an error when you try to open it. Usually, Image Renditions throwing error in SharePoint states that a Null Reference exception is happening. It’s a well known problem that happens since older versions of SharePoint. We can see the same problem in this post in the Technet community.  Since it may not be fixed anytime soon, I’ve wrote a simple JavaScript code. This script overwrites the custom function in the SharePoint JavaScript file that performs the modal open event.

Before diving into the problem/solution content, I must say that the Image Renditions are a nice feature for content publishers. It lets them save only one file version of an image in their SharePoint sites, but at the same time it allows the users to define the dimensions of an image and how you want to display them. The image renditions require that Blob Cache is enabled in the Web.Config to become available in the ribbon.

Image Renditions throwing error in SharePoint - Image renditions example
Image renditions example (Mastykarz)

Now returning to the problem, the bug is related to the URL being passed to the QueryString. It works fine when you try to edit an image located in the same site (SPWeb) you are editing content. The editing operation can occur when you work inside a page, a SharePoint library, a simple edit form, anything you want!

But if you edit an image rendition using an image stored in another site (SPWeb), like you are using an image from “http://sharepoint/sites/team/blog/” in a page located at “http://sharepoint/sites/team“, the error will show up because Team and Blog are different sites for SharePoint, even though they are in the same Site Collection. So SharePoint will look for an image inside Team that doesn’t exist!

Code snippet to fix error in Image Renditions

After you add this script to your Master Page, it will start working. The script will make the right calls to the ManageImageRenditions application page without problems. So the condition that causes the Image Renditions throwing error in SharePoint won’t occur anymore.

Also, if by any chance you don’t see the Image Renditions button, please check this post who might be helpful too!

References:
Technet discussion about the error
Cross-browser add event code

Missing Embed in SharePoint Online button in Power BI

This blog post will help you when you can’t find or it’s missing Embed in SharePoint Online button in Power BI. So you can explore the feature launched by Microsoft last year: the Power BI Web Part for SharePoint Online. It helps the users on embedding their reports in Modern Pages. The Web Part looks great and is really easy to use, requiring only the link for the report to work. For enabling it you can follow this guide for enabling the Power BI web part.

Once everything is right and you have inserted the Web Part in your page, but the button doesn’t show up, you can still do this workaround and keep testing the Web Part.

File menu without the "Embed in SharePoint Online" button
File menu without the “Embed in SharePoint Online” button
Continue reading

SPFx solutions not showing in Apps in SharePoint On Premises

This post will cover a solution for a new problem related to SPFx solutions not showing in Apps in SharePoint On Premises. Before diving in the troubleshooting, let me give you some context!

In September 2017, Microsoft announced support to the SharePoint Framework in the (not so new) SharePoint 2016.  It is a great feature that will let developers explore the new framework in the cloud and on premises, allowing them to embrace the new modern era of SharePoint with SPFx apps.

Also, if you don’t know anything about the SharePoint Framework, please read this guidance to get in touch with the new trends for SharePoint Development.

The step-by-step to explore this development is pretty straightforward. Just do as the Microsoft tutorial suggests to build a web part and have an environment prepared for apps in your SharePoint 2016 farm.

Some important notes are:

  • The SharePoint Framework version must be 1.1.0 to work on SharePoint 2016;
  • SPFx extensions are in preview for this version;
  • The SharePoint Web Parts will be presented as normal Web Parts in the Ribbon;
  • There is no modern experience available yet;
  • You must use a CDN or even the Style Library to store the published files;

If everything is fine, you can just upload your App Package to your App Catalog and it will work.

But that wasn’t my case… as you may now…

Continue reading

Repair Lookup column in SharePoint

Sometimes it’s necessary to repair Lookup column in SharePoint. Usually it can happen when we need to transport a list from a Production environment to a Development environment, just to reproduce some bug or situation with real world data. This is possible when you use the Save as Template feature, exporting it from an environment to another and then you recreate the list.

But, if you have Lookup fields it can give you some headaches. As soon as the list is restored in the other environment, the Internal GUIDs will be changed forever and any connection to the source list of the lookup column will be lost!

But it’s important to emphasize that Lookup columns are great as Microsoft says that “You can create relationships between lists by using a combination of unique columns, lookup columns, and relationship enforcement (cascade and restrict delete), all of which enhance your ability to create more sophisticated business solutions and help preserve the integrity of your data.”.

Continue reading

Troubleshooting errors using PowerShell in SharePoint

Today I would like to share with you an useful script to help on troubleshooting errors using PowerShell in SharePoint when some unexpected exception happens . This script can help you on tracing the exact cause of a bug in the application while relieving you from opening the entire log file and search for the error message in a not so productive way.

The SharePoint logs folder - Troubleshooting errors using Powershell in SharePoint
The SharePoint logs folder (Microsoft docs)

These logs are written by SharePoint and according to Microsoft, this is what you get from it:

“The Unified Logging Service (ULS) is the service that is responsible for keeping an eye on SharePoint and reporting what it finds. It can report events to three different locations:

  • SharePoint trace logs
  • Windows Event Log
  • SharePoint logging database

Where the event is logged (and if it’s logged at all) depends on the type of event, as well as how SharePoint is configured. The ULS is a passive service, which means that it only watches SharePoint and reports on it; it never acts on what it sees.”

Continue reading

© 2024 wiliammbr's blog

Theme by Anders NorenUp ↑