Writing client side code with Microsoft Dynamics 365

Client sided development in Dynamics 365 allow us to alter the user interface and influence how a user interacts with the application. In this context, I refer to client side code as that which primarily effects the user interface and is executed on the client machine. However, the lines are a little blurred at time, e.g. the XML driven elements are parsed on the server before rending on the user’s machine. We have the following options for client side code.

Continue reading

Getting started with coded development in Microsoft Dynamics 365

So you want to write some code do you?

This is a series of articles in which I will explore coded development and Microsoft Dynamics 365. I intend to produce a set of articles that will touch on key areas of coded development, with a focus on C# .Net development.

Continue reading

Clean Coding with CRM Late Bound Entities

This week I was speaking with Daryl LaBar regarding the respective merits of CRM Early and Late Bound Entities. I prefer Late Bound, to me it provides an easier, streamlined development experience. Daryl asked me to provide some example code to demonstrate my approach, so I’ve built a simple app to do so. I’ll accompany the app with some reasoning for a Late Bound preference.

console

Continue reading

Bench Update with Offline Tools

I’ve updated Woodswork Bench. Along with some visual stuff, it now also hosts my offline tools:

bench

  • Simplicity; built for Microsoft Dynamics CRM 2011 this tool provides Guid Mining, and URL Building services.
  • Determination; a light weight IronPython scripting tool specifically setup for Microsoft Dynamics 2011, however it suitable for use with any .Net assemblies and MSCRM version.

Check it out here.

Announcing Bench

I am happy to announce today the release of Woodswork Bench. Woodswork Bench is my latest personal project which provides a number of tools for the Microsoft Dynamics CRM community.

bench

Bench is a website which contains a collection of web based tools for working with Microsoft Dynamics CRM. These tools provide easy solutions to common MSCRM challenges. The initial release includes the following functionality:

  • Build URLs to open MSCRM forms.
  • Build URLs to open MSCRM views.
  • Finds the Guids hidden in MSCRM URLs.
  • Encoding and decoding of text.

Check it out here http://bench.woodswork.co.uk/.

I’m a relationship, I’m not a many to many, I’m not a lookup, what am I?

CRM has a two types of relationships:

  • One to many: a lookup on one entity, a grid on the other.
  • Many to many: a grid on both entities.

You are looking at a lookup. 90% of the lookups you see are simple, you can select one record of one entity type.

However, there are special system field lookups, namely the activity party. These muddy the waters a little. Some activity party lookups allow multiple record selections, some link to entities of multiple types. Which means you can have an activity party lookup with multiple records of multiple entity types. I suppose you could call this a “one to many (records) of many (entities)”.

For example on an email; the To field can be populated with multiple account and contact records. Whilst the From field can only have one record, but that can be a system user or queue. The To and From are both examples of activity party lookups.

To tell the difference programmatically you can use a RetrieveAttributeRequest. AttributeType shows if its an activity party, whilst Targets allows you see what record types are allowed in the lookup.

The following code shows how to do this for a couple of different fields.


RetrieveAttributeRequest attributeRequest = new RetrieveAttributeRequest
{
EntityLogicalName = "email",
LogicalName = "to",
RetrieveAsIfPublished = true
};

RetrieveAttributeResponse result = Service.Execute(attributeRequest) as RetrieveAttributeResponse;

Trace.WriteLine("Email - To");
Trace.WriteLine("AttributeMetadata.AttributeType: " + result.AttributeMetadata.AttributeType);
Trace.WriteLine("LookupAttributeMetadata.Targets: " + ((LookupAttributeMetadata)result.AttributeMetadata).Targets.CollectionToString(", "));

attributeRequest = new RetrieveAttributeRequest
{
EntityLogicalName = "email",
LogicalName = "from",
RetrieveAsIfPublished = true
};

result = Service.Execute(attributeRequest) as RetrieveAttributeResponse;

Trace.WriteLine("Email - From");
Trace.WriteLine("AttributeMetadata.AttributeType: " + result.AttributeMetadata.AttributeType);
Trace.WriteLine("LookupAttributeMetadata.Targets: " + ((LookupAttributeMetadata)result.AttributeMetadata).Targets.CollectionToString(", "));

attributeRequest = new RetrieveAttributeRequest
{
EntityLogicalName = "account",
LogicalName = "parentaccountid",
RetrieveAsIfPublished = true
};

result = Service.Execute(attributeRequest) as RetrieveAttributeResponse;

Which outputs:

Email – To
AttributeMetadata.AttributeType: PartyList
LookupAttributeMetadata.Targets: account, contact, lead, queue, systemuser

Email – From
AttributeMetadata.AttributeType: PartyList
LookupAttributeMetadata.Targets: queue, systemuser

Account – Parent Account Id
AttributeMetadata.AttributeType: Lookup
LookupAttributeMetadata.Targets: account

Originally posted on StackExchange here.

Using the CRM Audit Log to Rollback Records

Argh! Someone has done something and something is ruined! Fortunately someone only changed records in CRM, and even better audit logging was enabled. You can now use the web service SDK to analyse changes that have occurred, you can then use this information to perform the opposite action and roll back changes.

Continue reading