wiliammbr's blog

Some thoughts on SharePoint and other random stuff

Tag: JavaScript

Copying and Pasting images to your SharePoint Pages

One thing that I had to face and discuss at least once a month among Clients requests was: an easy way to paste images into SharePoint pages. Although my automatic answer was always “Just upload it through the ribbon, so you can tag and ensure the content quality”, I have to admit this way isn’t THAT user-friendly.

That’s why I decided to develop some JavaScript code to add this functionality to my Web Pages, so the users could be able to add their images faster. Basically, I’ve created a GitHub repository to keep the code, so maybe someone can help me on refactoring it or adding support for others browsers.

https://github.com/wiliammbr/sp-copypasteimages

The project is a SharePoint provider-hosted app that publishes some JavaScript files to your Site Assets library. It was based on some SharePoint projects in the PnP – Patterns and Practices, hosted by Microsoft. Also, it will add ScriptLinks to insert those script files into your pages. In my example, the app was hosted in an Azure Cloud Service.

Continue reading

Get user info programmatically in SharePoint

Once in a while we need to gather some user information and use it many ways. It doesn’t matter if you need to show a special message to an specific user using its Personal Name or maybe just fill an SPFieldUser in a specific list, you’ll probably need those snippets to do the trick.

I’m going to divide it into Server-side object model for C# users, REST API (for SharePoint 2013 projects or newer) and the old-fashioned JavaScript object model introduced in SharePoint 2010.
Continue reading

Hiding Empty Content Query Web Part

For those who want to hide their Content Query Web Parts if they don’t return any data and at the same, who don’t wanna dive into the XSL world, you can just add this code snippet to your pages and VOILÀ.

It’s up to you if you want to set this behavior to every page in your Web Site putting the code in a global JS file, or just for an specific one using a Script Editor Web Part to do the trick.

 

© 2017 wiliammbr's blog

Theme by Anders NorenUp ↑