by Daniel Halan
27. February 2012 06:44
Been working latly with Event Sourcing and the CQRS pattern. One of the great features of Event Sourcing is to be able to change the view model schemas and simply replay all the events and let the event handlers rebuild all your view models. No more deltas to think about. Been using the Jonathan Oliver EventStore library together with RavenDB.
Here is an example of a generic way of replaying all events, where all View Models stored in RavenDB implements an IViewModel interface. If you would have your IViewModel implementations in a different assembly from where the interface is, you will need to change the GetAssembly()-call to the correct one.
public void ReplayAllEvents() {
Type viewModelInterface = typeof(IViewModel);
Assembly viewModelAsm = Assembly.GetAssembly(viewModelInterface);
// Delete all View Models
using( var session = _readRep.OpenSession() ) {
MethodInfo miQ = session.GetType().GetMethods().Where( mi => mi.Name == "Query" && mi.GetParameters().Length == 0 && mi.GetGenericArguments().Length == 1 ).Single();
MethodInfo miDel = session.GetType().GetMethod("Delete");
foreach( Type type in viewModelAsm.GetTypes().Where(t => viewModelInterface.IsAssignableFrom(t)) ) {
foreach( var m in (IQueryable)miQ.MakeGenericMethod(new Type[] { type }).Invoke(session, null) ) {
miDel.MakeGenericMethod(new Type[] { type }).Invoke(session, new []{ m });
}
}
session.SaveChanges();
}
// Make sure the read model doesn't return stale results
_readRep.RegisterListener(new NoStaleQueriesListener());
// Dispatch all events again
foreach( var commit in _eventStore.Advanced.GetFrom(DateTime.MinValue) ) {
ServiceLocator.Bus.Dispatch(commit);
}
}
by Daniel Halan
24. June 2010 00:29
When working with Microsoft CRM data-types using web services there is no constructor parameters due to limitations of the WSDL code generation. This leads to few lines of code each time one want to create a variable of any CRM type.
This can be optimized using a Factory class where you encapsle the creation of the desired class. But one even cleaner way is to create a partial class and define "implicit" operators between CRM data-type and .NET data-type.
Here is an example on how it works.
Standard way of assigning a .NET DateTime to CRM DateTime,
CrmDateTime cdt = new CrmDateTime();
cdt.Value = DateTime.Today.ToString("s");
Using implicit declaration,
CrmDateTime cdt = DateTime.Now;
and back,
DateTime dt = cdt;
The code behind this,
public partial class CrmDateTime {
public CrmDateTime(DateTime dt) {
this.Value = dt.ToString("s");
}
public static implicit operator CrmDateTime(DateTime dt) {
return new CrmDateTime (dt);
}
public static implicit operator DateTime(CrmDateTime dt) {
return DateTime.Parse(dt.Value);
}
}
by Daniel Halan
19. May 2010 05:43
| Here comes a requested add-in for ouputting all your Microsoft CRM Customizations to a Word document.
This add-in can be used for various scenarios,
Documentation
- Document your work after it's finished, removing any possible mismatch from the specifications.
- Understand the work of others when taking ownership of a CRM instance without any documentations provided (Using the filters to export only Custom Entities, Attributes and Relationships)
- Presents all your ISV Configuration changes in one place, that usually are hard to get a good overview of.
|
 |
Daily work routines
- Development Aid, use a complete export document as a reference.
By searching in the document for a specific entity you can quickly see available picklist values, implemented javascript, published attributes on form and attributes schema name including data type restrictions.
- Architect Aid, Cut & Paste attribute, forms or relationships Tables to your specifications, and extend them with new values or describe changes.
|
The Add-in supports multi-language CRM installations, you select the prefered output language, and the base language will be used as fallback. You can also define to only export custom entities, attributes and relationsships making the document easier to read.
The document can contain following chapters,
- Organisation Settings
Configurations set for the selected organisation (tenant) i e Schema Name Prefix..
- ISV Configuration
All custom Menues, Navigation Items, Toolbar Buttons and Renamed titles
- Workflows
- Security Roles
- Entities
Checkout sample document, CCM Word Sample.docx (41,74 kb)
Only $99
|
|

Free version upgrades
|
Requirements Docx File Format Viewer Microsoft .NET Framework 3.5 or newer |
|
 |
by Daniel Halan
19. May 2010 04:16
First of all, I would like to thank for all the positive response regarding CRM Configuration Manager, always a joy to hear that the product works :)
Here comes a new release of CRM Configuration Manager that contains some improvements and a new Extension Framework for creating Add-ins. The first extension interface available is for output handling. You can now implement a new document type handler for exporting. Could be used for various documentation formats, for example an Visio document handler, that would create a data model of the exported entities and their relationships.
A SDK will be released in the near future, but until then you can contact me for guidance.
Improvements and bugfixes included in version 1.50,
- Improved 'Export only Modifications' function, now also checking modifications at Entity Forms and Relationships
- Not all system entities was listed in the Entity view.
Thanks to Daniel Jansen for reporting the issue.
- Implemented Add-in framework for output document formats.
- Revised user interface to improve usability
- Minor bug fixes
Complete list of features
CcmSetup1.55.exe (966,81 kb)
 |
Also released an output Add-in for Microsoft Word document format, read more about it here. |
Happy Customization!
|

|
by Daniel Halan
19. March 2010 01:50
There was a little bug / oversight in CRM Configuration Manager when working with CRM installations with other languages then English. Non-Latin characters didn't get saved correctly due incorrect encoding. It has now been resolved by checking what languages are installed at the server.
The fix is included in v1.15
Thanks to Daniel Sabater for reporting the issue.
by Daniel Halan
27. February 2010 18:55
This is a follow up on my earlier project CRM Customization Manager, CRM Configuration Manager is a Windows application to create an Export / Import selection that can later be exported as a command prompt string for later use, or execute directly inside the application. The main features of CRM Configuration Manager are,
- Easy access to the features of CRM Customization Manager
- Possible to select a CRM server as destination, allowing one click export and import.
- Create advance export/import selections for later use inside scripts / installations
This release includes CRM Customization Manager v2.0 that contains fixes and few new features,
- JavaScript Export/Import, This allows you to extract JavaScript to a local folder, where you can work in a proper script editor, and later import them back. You can also create new javascripts in the same folder, just follow the name convention and they will also be imported to the correct entity / event.
- Zip support, Now all features works with zipped customizations
- Include Related Entities, This features will automatically include related entities to the selected entities, so their relationships are exported and can be reviewed for conflicts. This is recommended during the development process when relationships may change.
- Publish Workflows, Publish operation now also publishes workflows
v1.0 key features...
|
I’m wondering, is there any interest in creating your own operations? That is, using a Plug-in model to add custom arguments to the application that will call your code before/after execution.
If you find the application useful, please donate to keep the development alive :)
[Update 2010-05-18] Version 1.5 Released, read more about it here
Get CCM v1.50
Happy Customizing!
|

|
by Daniel Halan
3. January 2010 06:24
If one would like to change a relationship lookup field name on a entity, then it is important to change the name of the relationship.
For example, We have an entity called “EntityA” and it has a N:1 relationship with “EntityB”, the lookup attribute is currently called “entityb_conntectedid” and we would like to change the lookup attribute to “entitybid”. Then you normally would remove the relation, and add a new one setting the new name “entityid” to the lookup attribute.
Then you have to change the “relationship name” from the generated name “new_new_entitya_new_entityb” to for example “new_new_entitya_new_entityb2”. Otherwise there will be a conflict when importing the customizations to a CRM system that contains the old attribute making it impossible to publishing the entity if the old field exists on a form.
In the upcoming version of CRM Customization Manager (v2.0) I’ve included a warning message if one tries to import a customization that has a different name of the lookup to the same relationship so one can spot this before CRM gets broken. Also if the relationship is exported CRM Customization Manager solves the problem.
If you already have imported the new relationship and cannot publish / import the Entity, you can fix it by editing the CRM database. Access the table “OrganizationUIBase”, filter it by the ObjectTypeCode of your custom entity, then removing all the references to the old attribute in the “FormXml” column.
Related errors:
Cannot Export Customizations From Microsoft Dynamics CRM 4.0
Update:
CRM Configuration Manager now handles this.
by Daniel Halan
17. December 2009 02:05
Validation of Social Security Number (Personnummer) or the Organisation Number is very common validation when working with business systems, here is a small method to validate the Swedish identification numbers. If you by any chance have done a similar check for your country social security number, would be nice if you post a link to your site or send the code and I will update this post.
IdNrCheck.zip (832 bytes)