Skip to main content

Posts

How to get SharePoint List or Library GUID via REST

Sometimes, you would need List or Library GUID to use that in some operation. In such cases, how do you get hold of GUID using REST API? There is a straight-forward end point which you can use: /_api/web/lists/getByTitle('ListTitle')/Id This will return the GUID of a List or Library. There is also another approach. However this approach works only if a List or Library contains at least one item. /_api/web/lists/getByTitle('ListTitle')/items This is a familiar end point which we use to fetch items of a List or Library. To get the GUID from the response, you would do: var listIDTemp = response.data.d.results[0].__metadata.id; var listID = listIDTemp.substring(listIDTemp.lastIndexOf("guid") + 5).split('\'')[0]; As you can see, we are doing string operations to fetch GUID from metadata.id. This contains information only if the response has at least one item.

Difference between Choice and Lookup fields in SharePoint

When you have to provide users an option of selecting a value from a list, you can go for a Choice field or a Lookup field. Have you ever wondered which one to use and when? Which option should be chosen over other? To address these questions, one need to understand the differences between these two data types in SharePoint. This post outlines these differences to help users decide the appropriate column type based on their needs. Factor Choice Lookup Permission To add values to a Choice field, you need minimum Design permission To add values to a Lookup field, you need minimum Contribute/Add permission Changing existing Values If you change a value in a Choice field, it does not affect the existing values. For example, let us say one of the values was NY and there are items with this value. If you change it to New York in the field schema, it only affects the new values. All existing values will retain NY. If you change a value in a Lookup field, all the existing rows re...

One of the properties of the Web Part has an incorrect format

I was trying to insert a Content Editor Web Part (CEWP) to a Master Page. I used the recommended route of using Design Manager. Let me share the steps if you are new to this: 1. Navigate to Site Settings 2. Under Look and Feel, click on Design Manager 3. Click on Edit Master Pages and click on perticular Master Page which you would like to edit (before editing, ensure you have a copy of the file for backup) 4. Click on Snippets 5. In the Snippet Gallery, insert CEWP, and set the web part properties 6. Click on Update button 7. Copy the HTML snippet generated and paste it in the Master page (.html file) 8. Upload the [[Master Page]].html file and publish With this approach, you can attach any custom HTML/JavaScript which you would want to execute in all the pages in a site. After publishing the master page, when I refreshed the page, I got the below error: One of the properties of the Web Part has an incorrect format. Microsoft SharePoint Foundation cannot deserialize the ...

Business Connectivity Services - Authentication from the browser

Understanding how BCS works with different types of authentication is not that easy, unless you have an excellent resource which explains in a simple but effective way. I was looking for such resource and I stumbled upon this video. When I watched this 36 minutes video, I was impressed with the way the Presenter has put it across. This video takes SQL Server data source as an example and explains how different kinds of authentication works in BCS such as User's Identity, BDC Identity, Impersonate Windows Identity, and Impersonate Custom Identity. Do watch this video to understand the concepts of authentication from the browser in BCS.   Video Source

Maintaining Multi-line text format in AngularJS View

I was using AngularJS framework in SharePoint site and was trying to fetch data from a List and display using AngularJS view. The List had Multiple Lines of Text column with Rich Text enabled. The HTML markup looked like this: <p>{{description}}</p> Here description contains value from multi-line text field. However, it trims the HTML part and display only plain text. I even tried using ng-bind-html as: <p ng-bind-html="description"></p> This also didn't solve the problem. This is where Angular filter came to the rescue. Solution: First we need to create a filter: var myApp = angular.module('myApp', ['ngSanitize']);  myApp.filter('trusted', function($sce){     return $sce.trustAsHtml; }); Note that, with this filter we are returning the HTML as trusted. Now, this filter should be used in the HTML: <p ng-bind-html="description | trusted"></p> This would keep the format intact...

Multiple Lines of Text column value is blank in SPD Workflow

This is a strange behavior I observed recently. Let's say you have a List with Multiple Lines of Text column. In the column setting, ensure "Append to existing values" is set to No. Now create a SPD workflow on this List and try to access the column value (just log this value to the workflow history list). When you create an item and put some value to this column, you can see the workflow history displaying the correct value. Now the not-so-cool part: Go to column settings, and change "Append to existing values" to Yes. Add a new item to the List. Go to the workflow history. Alas! The value is blank! In the SPD workflow, whether you set return value as "String" or "Plain Text", it always return blank! Summary: If you are dependent on the value of Multiple Lines of Text column in SPD workflow, ensure you have not set "Append to existing values" to Yes.

When Folder is created, Name property is blank

This is a strange behavior I noticed recently and hence thought of sharing through a post. In a Document Library, create a folder. Now for the newly created folder, click on ellipses (three dots) and click "View Properties". Surprisingly, Name property is blank! However, you can still navigate to the folder and upload files to this folder. This seems to be a bug. Now go to "Edit Properties", you can see the value in textbox. Click Save. Again go to "View Properties" and now the Name property is showing the value. I found this behavior when I was trying to create a folder using REST API. Totally surprised with this behavior, finally I posted a question in StackExchange . To my relief, I was not the only one facing this behavior! Hope MS will fix this basic issue soon!