Skip to main content

Posts

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!

How to get Document Type Icon using MapToIcon REST Endpoint

If you look at a Document Library View, you will also notice Document Type column which shows the icon corresponding to the Document Type. If it is a word document, it shows MS Word symbol as shown below. Document Icon is highlighted There could be scenarios where you would need to display the documents in a custom view and you would also want to make use of these icons. However this is not a very straightforward approach and this post will show you how to get that! I was using REST API to get items from the library. So obviously I was looking at any column which would give me access to these icons. When I got into the columns in the response, the one which caught my attention was the field "DocIcon". But, this field contains only the extension of the document. For example, "docx", "html", "jpg" etc. So DocIcon was of no use as I wanted to get the image URL. I also started looking at any endpoint which would get me this URL. During t...

How to update Person field with multiple values using REST API

Person or Group field in SharePoint is similar to a Lookup field. When you are updating this field using REST API, you need to append "Id" to the name of the column in the body construct. For example, the body construct looks like this: data: { "__metadata": { "type": "SP.Data. ListName ListItem" }, "Title": "First Item", " PeopleField Id": "4" }; The highlighted portions should be replaced by the actual List Name and Column Name. In the above example, the REST call is updating a List item with Title and People columns. How to get the value for user ID ("4" in the above example) needs a separate explanation and that will be my next post! The above example works fine if Person field is configured to accept only one value. If we change the Person field to accept multiple values, how do we pass more than one value in the REST call? Since we normally separate user names with semicolon in peop...

Error: Not enough storage is available to complete this operation

This is the first time I noticed this error message since I started working on client side programming in SharePoint. I have REST API code to pull data from multiple Lists and I'm calling this script in a page through Content Editor Web Part. The error message is not shown on the page. However, the web part is empty without any data. So I turned on the Developer Tools Console to check for any clue. This is where it promptly displayed: Error: Not enough storage is available to complete this operation First thing it stuck me was to check my machine's RAM usage. When I checked in Task Manager, RAM usage was more than 80%. I had opened lots of IE tabs. I closed a couple of browser tabs and RAM usage came down to 50%. I refreshed my SharePoint page and alas, it is showing data as expected! A few questions that came up in my mind: Can we catch this exception so that we can show the user-friendly message instead of the blank web part? How do we optimize the overall ...

How to set character limit for Multiple Lines of Text column in List

Setting a character limit for Multiple lines of text column in a List is not straight forward. Depending upon the setting of the column, the solution varies. Plain Text: When you create Multiple lines of text column with "Plain Text", SharePoint renders this field as "TextArea" HTML element. You can set the character limit by making use of maxlength attribute of TextArea element. $ ( document ). ready ( function () {     $ ( "textarea[id*=FieldName]" ). attr ( 'maxlength' , '1000' ); }); The above script should be injected into NewForm.aspx and EditForm.aspx of SharePoint List. Of course, replace "FieldName" with your field name. Enhanced Rich Text: When you create Multiple lines of text column with Enhanced Rich Text, SharePoint renders this field as DIV with contenteditable attribute set. This is where it gets more tricky. If you closely observe, the IDs of the contenteditable DIV and the corresponding Label D...