wiliammbr's blog

Some thoughts on SharePoint and other random stuff

Tag: SharePoint

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

Recovering corrupted Lookup Columns

Sometimes we need to transfer a list from a Production environment to a Development environment, just to reproduce some bug or situation with real data. It can achieve by the Save as Template feature, exporting it from an environment to another and then recreating 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 are changed an any connection to the source list of the lookup column will be lost:

The option Get information from will be empty and the column name will be a span, not a a dropdown. where you could select which field should be presented:

Continue reading

Improving your SPQuery performance on SharePoint

So many times I’ve seen my clients complaining about the performance of their Sharepoint sites. That of course collaborated to create a bad impression of the product. “The page takes too long to load” or “Web Parts with pagination are terrible” were some of their protests.

After the first contact with them, I usually asked for the source code to find out what was happening. It didn’t take too much to find out that almost every case there were happening due queries being made with SPList.Items property and followed by some LINQ query to filter the data.

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

Study Guide for Exam 70-488 – Developing Microsoft SharePoint Server 2013 Core Solutions

Since last year, we received the announcement that some of the SharePoint 2013 certifications were being retired in September of last year. But after that, they extended the deadline to 2017. This new deadline can be explained due there is no new certifications focused on development for SharePoint 2016 have been released yet.

Exam on Microsoft’s website: https://www.microsoft.com/pt-br/learning/exam-70-488.aspx

Therefore, here is a set of links that you can use as a study guide to pass on that exam before it is retired.
This summary was once made by Martin Bodocky and kept on this blog post “70-488 – Developing Microsoft Sharepoint Server 2013 Core Solutions – Preparation links“. Unfortunatelly, it’s not online anymore, so I decided to provide this information once again at the same time that I must say: Bodocky made everything and helped me on passing this exam, back on 2014.

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 ↑