Dynamics365 OData string filtering

If we want to use simple filter in D365 OData endpoint, we’d use something like:

https://myinstance.dynamics.com/data/Workers?$filter=PersonnelNumber eq '123'

However, when we want to filter only the items which begin with a certain string, it is not possible in D365 to use the OData convention like ’startsWith’.

Luckily, the following wildcard (*) is possible:

https://myinstance.dynamics.com/data/Workers?$filter=LastName eq 'Smit*'

Or even the wildcard on both sides:

https://myinstance.dynamics.com/data/Workers?$filter=FirstName eq '*von*'

Hope this helps.

SharePoint 2013 Search CSOM default row limit

Could be an interesting hint for those using CSOM search API: why are some of the results not returned?

Is it trim duplicates setting? No.
Is it some wildcard settings of the result source? No.

If you do not set the row limit of the query, you will get by default only 50 items. However, you can increase it like that:

var query = new Microsoft.SharePoint.Client.Search.Query.KeywordQuery(searchContext);

Last line does the trick. Please note that – by default – 500 is the maximum value.

If you need to increase it, you can do it e.g. via Powershell for the entire search service application:

PS> $mySearchServiceApp = Get-SPEnterpriseSearchServiceApplication
PS> $mySearchServiceApp.MaxRowLimit = 2000
PS> $mySearchServiceApp.Update()
PS> iisreset

Hope it helps,

Generate PDF with different encodings using iTextSharp

Let’s assume a following scenario in iTextSharp:
You need to generate a PDF, which would contain text in two or three languages, each of them having its own special characters – for example: German, Italian and Polish (or another Eastern European language).
If you use the standard way of getting fonts, like:

BaseFont baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, false);

…you will stumble upon a problem, that, using the CP1252 encoding (Latin), the Italian characters with accents are displayed, the German „Umlaute” are displayed, but the Eastern European special characters are not rendered at all in the PDF. On the other hand, using CP1250 encoding (Eastern European), displays the Eastern European characters, but not the Italian special characters with accents, for instance.

First idea would be to use some Unicode or UTF-8 to solve the problem – the „Identity-H” encoding option of iText sounds interesting here. But not with the Helvetica that’s shipped by default.

We could give Arial Unicode a try then, but it is not listed in the enumeration of BaseFont of iText.

Let’s load the font from disk then, and embed it into the document, making sure that all clients will be able to read it properly.

Here is my code snippet that does the trick:

String encoding = BaseFont.IDENTITY_H;
String fontName = "ARIALUNI.TTF";
String fontProjectPath = "MyProject.Namespace.Path." + fontName; // this path contains first the default namespace of your assembly, then the folder path within the project

// loading font from an embedded resource file, in order to avoid any file-system dependencies
using (Stream fontStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(fontProjectPath))
using (MemoryStream ms = new MemoryStream())
BaseFont baseFont = BaseFont.CreateFont(fontName, encoding, BaseFont.EMBEDDED, BaseFont.CACHED, ms.ToArray(), null);

What happens here? It loads the file from the assembly, into memory, and creates the font from the loaded file, embedding it additionally into the PDF document.
Now the document contains both Eastern European and Latin special characters.

Hope this helps.

SharePoint 2013 Content Editor – zero width space characters

Sometimes, the content editor web part of SharePoint 2013 adds unwanted characters to the text within it. You check once, twice, remove any unnecessary line breaks, spaces etc., but after saving or in the HTML source of the page you find these weird characters: ​ – the zero width spaces (& #8203;)

They can mess up your CSS layout, and frankly, I have not found a solution to force SharePoint not to insert them.

One possible workaround would be to remove them with a library like jQuery, e.g.


$(’.ms-rtestate-field’).each(function(index,element)  {
var theeditor = $(element);

The selector applies to the content editor webpart of SP2013.

Hope this helps.

SharePoint 2013: Get item order ID in the search results display template

In SharePoint 2013, when creating a custom display template for an item, sometimes you need to know, which item in the whole search results list it is. In other words, you need the information of which item in the whole sequence that is, and perform your own logic according to the parameter.

I’ve looked for the property quite a while, but finally found it. It is called piSearchResultId.

Practically you can call it like that in your display template:


It’s value is similar to the following:

0_1 for first item in the list
1_1 for the second item
2_1 for the third item
…and so forth.

With such values you can extract the first number, and there you go!

Hope this helps,

Fiddler full of /vshub/ requests

Recently, when debugging with Fiddler and Visual Studio 2015, I got a lot of requests in the Fiddler list, that weren’t relevant for the work I wanted to accomplish. Actually, they were making a mess, preventing me from finding the desired requests to inspect.
I am talking about the /vshub/… requests, and I mean really a lot of them, like dozens in a second, e.g.:

Czytaj dalej „Fiddler full of /vshub/ requests”

Please wait for system event notification service

This is a very nasty error which happens from time to time on Windows 2008 R2 machines.
A user tries to logon to the machine via RDP, or perform a logout. The screen he sees is hanging with the following message:

Please wait for system event notification service

Of course, one solution is to reboot the machine.

What if it is not possible due to certain reasons?

You can read a lot about it on the web, but none of the solutions was suitable for me.

The first option is to go to run services.msc and try to restart the „System Event Notification Service„. In my case it failed with a message, that the service could not be restarted because it did not respond in a timely fashion.

Last resort, a bit hardcore, but working:

  1. On the machine, run the command prompt as an administrator
  2. type sc queryex sens
  3. you’ll get some properties, including the process ID (PID), e.g. 123.
  4. Now you can kill the process with following command: taskkill /PID 123 , using the PID from previous step
  5. You should get a message „SUCCESS: The process with PID 123 has been terminated.
  6. If it still does not work, use the force parameter, like this: taskkill /PID 123 /F
  7. Then, go back to services list, and start the System Event Notification Service

Hope it helps.

Failed to query the OAuth S2S metadata endpoint

Upon registration of workflow service in SharePoint 2013, running the following command in SP Management Shell:
[powershell]Register-SPWorkflowService -SPSite http://testsite/sites/workflow1 -WorkflowHostUri https://testsite:12290[/powershell]
the following error is displayed:

Register-SPWorkflowService : Failed to query the OAuth S2S metadata endpoint at URI http://testsite/sites/workflow1/_layouts/15/metadata/json/1 .

Error details: 'The metadata endpoint responded with an error. HTTP status code: Forbidden.

It seems that the permissions are missing (403). However, if you open the indicated JSON URL with IE logged in as admin, you get the expected result.

In order to resolve this issue:
1. go to Central Administration
2. Manage Service Applications
3. Select the Workflow Service Application
4. In the ribbon bar, click on „Administators”, add tha Farm Admin and grant him full control.

Re-run the shell command, it should now run smoothly without error.

Hope this helps,

Windows Phone Emulator wasn’t able to connect to the Windows Phone operating system + Invalid pointer

Hello there,

recently I encountered a problem trying to start a Windows Phone Emulator from within Visual Studio 2012. In a WP8 project, starting a debugging session effected in loading the emulator box, but then right away stating the following:

The Windows Phone Emulator wasn’t able to connect to the Windows Phone operating system:

The emulator couldn’t determine the host IP address, which is used to communicate with the guest virtual machine.

Some functionality may be disabled.

The WP8 app did not start, all I could see was the main tiled page of the emulated phone. Additionally, Visual Studio reported an error: „Invalid pointer„.

Some sources on the web state that this might me caused by an interference between e.g. VPN client software and the emulator network usage. It was not quite what I would want to do, and luckily I found another solution:

  1. Started Hyper-V manager
  2. Virtual Switch Manager
  3. Removed the „Windows Phone Emulator Internal Switch” from the list, and applied the changes.

Starting the emulator afterwards required an elevation of privileges for the system in order to create the switch again, this time without any conflits.

Et voilá, emulator does not seem to have connectivity problems anymore, the debugging works as it should.

Hope it helps,



Facebook page tab app not showing

Hi there, just a quick one this time.

Today I struggled for some time with a Facebook app, which was meant to display as a page tab. A basic functionality: take an external URL and display it within the page tab. 

The problem was that the page was not appearing, although the server was publicly available and pasting the URL in a browser worked as expected. After some research, it came out that the URL using commas and semicolons in querystring has to be encoded, otherwise Facebook won’t like it.

Thus, changing from http(s)://www.example.com/page.html?a=1,2&b=3;4



seems to solve the problem and the page gets displayed.

Hope this helps,