wiliammbr's blog

Some thoughts on SharePoint and other random stuff

Category: Customization

Sync SharePoint files with Visual Studio Code

The last three months I’ve been working less with SharePoint and more with Angular 4/Node JS projects. This change forced me to use less Visual Studio and dive deep into Visual Studio Code in almost every task.

While working with VSCode, I’ve been testing some Gulp tasks like SPSave and SPSync for automatizing file changes to SharePoint, just for fun. Because I just can’t accept SharePoint Designer anymore, my patience with it ran out.
Also the Windows feature to map a network drive to a SharePoint library isn’t good too, at least for me.
So basically the gulp tasks did the trick, but they aren’t that easy to be understood for some more “traditional” programmers in my company, which would end with few adopters here.

So while searching for SharePoint extensions just for curiosity, I found the SPGO Extension and it really impressed me!


Continue reading

“Access Denied” when activating Feature with custom Timer Job

Sometimes we have to develop an automatized routine that must run in an specific schedule in your SharePoint site. This routine must complete some tasks, send e-mails, whatever… you name it! That’s why we develop SharePoint Timer Jobs and they work quite well.

If you know how they work, you probably know they are usually deployed with a Feature Receiver that adds to the Farm during the deployment process.

But let’s say if your SharePoint administrator forgot to activate it and you had to do it manually. Or if you are in an development environment and you want to debug the Feature receiver to find a bug.

So you are browsing to the Manage Features page, you find the feature and then suddenly an exception happens presenting a message of Access Denied!
Continue reading

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

“You are not allowed to respond again to this survey” message on SharePoint

One of my favorite list templates in SharePoint is the Survey. It’s a fun and useful feature that helps you on achieving a good survey-like form with charts and insights. You can make them anonymous, do some customizations and add Branching Logic, which means conditional questions depending on what the user answers.

Form example

Survey overview

But it has one main behaviour that I just don’t like, that is the message when you try to answer the survey again. Below you can check the message with Custom Errors disabled.

Message: You are not allowed to respond again to this survey

 

Theorically, the user has the required permission to edit its answers. But unfortunatelly once I try to answer again, SharePoint shows me that message as an error. This is a huge problem for users that don’t understand this message and it can be negative to the system.

Continue reading

Complete Operations on Lists with CSOM

Sometimes we have to reach a SharePoint list through remote connections using C#. It can happen in a SharePoint App, a Console Application or maybe on an Azure Worker Role.

Below you can find some code snippets that will help you on integrating SharePoint lists with your application.

Basically, you will have to add the Microsoft.SharePoint.Client namespace.

using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;

The required DLLs for programming these type of solution are:

Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll

You can find them inside those folders:

SharePoint 2010: 14 Hive -> Folder: ISAPI

SharePoint 2013: 15 Hive -> Folder: ISAPI

Or just download it from MSDN, inside the SharePoint Server 2013 Client Components SDK!

After adding these references to our project, we can start coding.

Soon you will notice that everything depends on the ClientContext object, which manages the requests and the data that will be loaded.

In our examples we are going to use the variable siteUrl, that represents the URL for the Site Collection. The variable listTitle will also be used and it represents the Title of the list being used.

string siteUrl = "http://sitesharepoint";
string listTitle = "SharePointList";

So, let’s do some real stuff here:

Reading SharePoint lists:

Filtering SharePoint lists and selecting specific fields:

Creating list items:

 Updating list items:

 Deleting list items:

I believe these are the basics for consuming SharePoint lists. In the future I’m planning to show some complex examples, more focused on Office 365 and Azure integrations. Thanks for reading and I hope it can be useful to you

References:
MSDN

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 ↑