Some thoughts on programming stuff

Category: General (Page 5 of 7)

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

How to delete a SharePoint Site Collection

When a Site Collection is not necessary anymore, you may need to delete it. So how to delete a SharePoint Site Collection? This tutorial will guide you on deleting that Site Collection!

But before I start writing in how to do that, it’s important to explain what is a Site Collection if you don’t know exactly what it is! According to Microsoft documentation: “A site collection is a group of websites that have the same owner and share administrative settings, for example, permissions, and quotas. Site collections are created within a web application. When you create a site collection, a top-level site is automatically created in the site collection. You can then create one or more subsites below the top-level site. The entire structure of the top-level site and all its subsites is called a site collection.”

Continue reading

Get web URL from document URL in SharePoint

Maybe you need to get web URL from document URL in SharePoint, or even just grab the Site Collection URL and do some awesome logic and update some data in your site. But you are aware that it can be costy and require some array splits, substrings and those kind of tricks. So here is a code snippet to save your time to enjoy a good cup of coffee with your colleagues!

The document URL usually is composed by a site collection part, the specific web part, the Library name and then the final part containing the folders and the file name. The script basically will perform a request to a SharePoint API. Our parameter is the folder or library URL (cutting the filename) that will be made automatically. Finally, the result will come with the Web and Site Collection urls for that context.

Get web URL from document URL in SharePoint - A bunch of files in folders inside drawers (SharePoint)
A bunch of files in folders inside drawers (SharePoint) (Source: Howtogeek)
Continue reading

How to delete a SharePoint site

When a SharePoint subsite is not necessary anymore, you may need to delete it. So how to delete a SharePoint site? This tutorial will help you on deleting that site! Oh, needless to say that you can restore it from the Recycle bin if you want, for a period of time.

Before you advance to the method itself, it’s important to say what is a SharePoint site. There’s a lot of misconceptions between the words Site Collection and Sites. Even the SharePoint Admin interfaces calls a Site Collection as “Site” sometimes.

According to Microsoft documentation the sites objetive can be described like the paragraph below:

“You create sites in your site collection to partition your content so that you can have finer control of the appearance and the permission to the content. You can also have different features available on the various sites in your site collection. You can use a site template with its default configuration, or you can change the site’s default settings through site administration, and then save the site as a new template”.

It’s nice to share that there’s another name to a SharePoint Site from a Dev perspective, we call it a SPWeb.

Continue reading

How to open SharePoint settings?

It may sound basic to teach how to open the SharePoint Settings page, but it can help someone that is stepping inside the SharePoint world for the first time. Also this post will be used for referencing purposes in other step-by-step tutorials, reducing the post size for those who need to do or access something inside the Settings page. That’s why this post will cover how to open SharePoint settings.

Te settings page allows you to do a lot of things! According to Microsoft docs: “Once you’ve created a site in SharePoint Online or SharePoint Server, you can make changes to the settings, information, and permissions for the site.”. You can also define some advanced settings if you are a site owner or site collection administrator.

Continue reading

Optimize your SharePoint dev environment

If you optimize your SharePoint dev environment, you will be more productive. We must agree that SharePoint demands a lot of resources to run smoothly, which usually is not the case of common standalone installations used by developers to code and test.

In this post I’m going to cover some basic settings that will help on your mission to optimize your SharePoint development environment, performing better when debugging, browsing and customizing your SharePoint on-premises projects.

Continue reading

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

Default Page in Publish to web from Power BI

If you have to embed a Power BI report to a SharePoint Online Classic Page, then just go for the iFrame approach. Power BI offers a “Publish to web” feature that helps you on embedding reports easily. Although it’s not so interactive and have some limitations (can’t use Query string filtering), it still works well and offers some parameters like the possibility to set default page in Publish to web from Power BI.

We are going to cover the steps for embedding and setting a default page for our report!

Continue reading
« Older posts Newer posts »

© 2024 wiliammbr's blog

Theme by Anders NorenUp ↑