Dutch Dynamics365 / CRM User Group

Working in both the SharePoint and CRM / Dynamics365 products gives you some good insights on how things are done in other products. Especially with regards to updates, tooling and communities. SharePoint has a vibrant community and the community has always been very open and welcoming. Here in The Netherlands we have the very active Diwug with a focus on Office365 and SharePoint and there are more usergroups around Offic365.

When you’ve experienced such an open community where people with a passion for the product share knowledge and experience around the product in an informal way, you long for it in other products as well. Most certainly in CRM.

The Dynamics world seems te be a bit more closed than the SharePoint and Office365 world. Especially in The Netherlands. So there’s no user group in the style of other user groups found abroad or in SharePoint. Where you can just signup for events, attend for free and that’s organized amongst enthousiast.

I’ve been thinking about starting an user group for a while now, using the popular Meetup platform. Only after my co-worker Marc Gerner started to talk about it, we’ve decided we would create this new user group. We’re hoping that we can encourage enough people to join and to actually organize the first meeting.

The Meetup page has been live for a week now. If you’re interested in joining, please signup. There’s no hidden agenda, we just want to create a group of Dynamics365 / CRM enthousiast and share knowledge and experiences.

Nederlands

Wanneer je zowel met SharePoint als CRM / Dynamics365 actief bent, dan krijg je goede inzichten in die zaken die verschillend zijn in beide groepen. Zeker wanneer het gaat om zaken als updates, tools en communities. Zo heeft SharePoint een zeer levendige community die erg open is. In Nederland heb je bijvoorbeeld de Diwug die zich richt op SharePoint en Office365. Er zijn echter nog meer user groepen rondom ditzelfde onderwerp in Nederland.

Wanneer je ervaren hebt wat een user groep kan betekenen, met een open en informele sfeer, waarbij enthousiastelingen kennis delen met elkaar, dan krijg je ook de behoefte om user groepen met andere onderwerpen te bezoeken. Voor mij dan met name in CRM / Dynamics365. Helaas is zo’n user groep, naar mijn idee er nog niet. Zeker niet één waar je als individu kunt deelnemen, kennis kunt delen met anderen en je gratis events kunt bezoeken. De Dynamics wereld is helaas wat meer gesloten, zeker in Nederland.

Ik liep al een paar maanden rond met de gedachte om een user groep met die insteek te gaan starten en daarbij gebruik te maken van Meetup. Pas toen mijn collega Marc Gerner er ook over begon, hebben we vrij snel de knoop doorgehakt en hebben we een de pagina gelanceerd. Nu hopen we genoeg mensen te bereiken en enthousiast te maken om deel te gaan nemen aan deze groep. We kijken er al naar uit om het eerste event te organiseren.

De Meetup pagina is nu ongeveer een week live. Wil je ook kennis delen met andere enthousiastelingen? Schrijf je dan in en neem deel aan deze Meetup.

Using alternate keys with the WebApi

Alternate keys are very powerful feature in Dynamics 365 / CRM. Especially when you are integrating with other systems it’s very helpful to use alternate keys to efficiently retrieve and update records. In this blog post I’ll guide you through creating alternate keys and using them in retrieving, updating and upserting records.

Creating an alternate key

The first thing you need to do is to create a field that holds the alternate key. Please keep in mind that you can only use the field types: Decimal Number, Whole Number and Sinlge line of text for an alternate key. There’s also a maximum of five alternate keys per entity and a restriction in size. For a full reference visit the documentation.

When you created the field you need to go to the keys of the entity and create the alternate key. The key can be a combination of multiple fields. In this example I kept it simple by using one field:
crm-creating-alternate-key

For the key to work, a system job needs to run to create an index. Please check if this is successful. The key I created for this blog post had an error on the first try.

Creating an account

Setting the alternate key in the request is the same as setting the value of any other field:

Retrieving a record

Retreiving a record is quite simple. Normally you would use a get request to /account(0000-000-000-000-000) to retreive a single record using the guid of the record. Using an alternate key the request is this:

Here you can see that instead of using the guid, you need to use the field name of the key (not the keyname) and the value to retrieve the account.

Updating a record

The sample to update the record:

The nice thing with the PATCH request like this is, that by default it will update the account if it exists, or it will create the account if it doesn’t exist. This is a great feature for integration scenario’s with other systems.

Navigation properties

You can also use the alternate key for setting a lookup value. In this example we will create a contact for the account created above.

Conclusion

Alternate keys are a great feature, especially when you’re integrating with other systems. It’s good to see that the WebApi has full support for this, even with upsert requests and using it in navigation properties. This saves writing a lot of logic and a lot of calls getting guids from Dynamics365 / CRM.

WebApi batch request

The WebApi in Dynamics CRM has the option to send batch requests. This reduces the number of calls from client to server and when e.g. you need to delete a lot of records from JavaScript it saves time processing these deletes.

Unfortunately, creating a batch request is not as straight forward as doing a POST call for example. The MSDN documentation is a good starting point, but then I still had some trouble making it work. I’ve created a question on stackoverflow and the Dynamics Community. As I needed the functionality I kept trying different options and reading the documentation and I finally figured it out.

It’s very important that you build the content in the batch request as documented with MSDN. Also note that when you do a delete batch request you still need to send an empty object. With a single delete call to the api you don’t have to explicitly do this. Another things that’s a bit hard creating a batch request, the errors that are returned are not existent. You just get an empty result and you have to figure out yourself what you have done wrong.

This is the request if you’re using jQuery to do the call.

And here’s the way to build the payload: