Thoughts on Microsoft Dynamics CRM Strategy

All failure is failure to adapt, all success is successful adaptation.”
― Max McKeownAdaptability: The Art of Winning in an Age of Uncertainty

Strategy is about shaping the future.  Look at how you can win, where the opportunities are, create actions develop knowledge, skills and resources to deliver the strategy.

Strategy is important because what brought a company success in the past might not work in the future, you must keep evolving at a company.

Successful companies are those who adapt to their changing environments, those who understand the direction of an industry, create and deliver strategies suited to opportunities arising from change.

“Change is inevitable, progress is not.”
― Max McKeownThe Truth About Innovation

Do I need to know about strategy

Individuals need strategies to progress, the skills and knowledge you have might not be in demand in the future, you must learn new skills, technologies to adapt to new roles.

You might think I don’t need to know this, it doesn’t affect me, I go to work, do my job and go home at 5.30 but what about?

What technologies will in the next Microsoft Dynamics CRM project, it could be CRM Online, portal, Azure services, Machine learning, gamification.  Could you deliver this project or will they need to hire someone else?

What are you going to learn next? if you pick one new technology used in Microsoft Dynamics CRM which is it? why did you choose that? is it the best choice?

You are making strategic decision’s daily but if these are not linked with your future vision, you could be investing your time and energy into areas not helping to progress your career.

Plain and Simple

I’m reading the excellent book Leadership:Plain and Simple: Plain and Simple (2nd Edition).  It discusses when John Harper become UK Managing director of Hasbro (a global toy company), when he came in things were in bad shape, losing money, morale and confidence were low.  His plan was to energise and engage the workforce.  He closed the company for a day and they discussed the ideas

  1. What is the future we want want and how great can we be?
  2. How do we play to win and perform at our best
  3. How do we build relationships internally and with customers, so we can deliver the future together as a team.

The questions are direct and decisive, they create a vision of the future and create a strategy to make it happen.  A leader cannot do the work himself, he needs to inspire the workforce deliver the vision.

These quotes highlight the role of a leader and limitation of a leader because without an engaged workforce they have no one to implement the strategy

A leader has the vision and conviction that a dream can be achieved. He inspires the power and energy to get it done.”
— Ralph Lauren

“A leader’s role is to raise people’s aspirations for what they can become and to release their energies so they will try to get there.”
— David Gergen

The book Playing to Win: How Strategy Really Works simplifies strategy to these two questions

  1. Where to play?
  2. How do you win?

Successful companies answers to these two questions seems obvious

Apple

  • High end smart phones and gadgets
  • beautifully designed, easy to use, high quality gadgets

Facebook

  • Social interaction
  • easy to use, different methods

Microsoft and Microsoft Dynamics CRM

To help me understand the questions I would answer the questions if I was head of the Microsoft Dynamics CRM division.  I wrote about the evolution of Microsoft Dynamics CRM in the blog The rise of Microsoft Dynamics CRM

1 – What is the future we want want and how great can we be?

The Microsoft Dynamics CRM strategy filters down from the global strategy of Microsoft – Mobile First, Cloud First.

  • The future for Microsoft Dynamics is Microsoft Dynamics CRM Online.
  • Improve the Microsoft Dynamics service,  redesign the internal design of to incorporate azure’s scalability to improve performance.
  • Improve the mobile functionality to match Resco
  • Microsoft Dynamics CRM act as a hub, linking to many specialist services (Machine learning, Big data analysis), Microservices/app structure.
  • Portals used more, allowing CRM deployments to offer self service portals, contractor functionality and extending CRM to none CRM users.
  • Social CRM to really take off

2.  How do we play to win and perform at our best?

Ask yourself what is Microsoft good at? why do people choose Microsoft Dynamics CRM?  Office Integration, competitively priced, cloud solutions/Azure functionality is world class.  Microsoft are constantly innovating Microsoft Dynamics CRM and surrounding products.

  • Keep improving Microsoft Dynamics CRM
  • Purchase strategic Microsoft Dynamic Solutions/companies
  • Keeping prices cheaper than Salesforce.
  • Microsoft can continue to benefit from improved Azure functionality and an increase in Azure services and data centres.
  • Microsoft must improve their mobile application or buy Resco
  • Strategic purchased of related services.

3 – How do we build relationships internally and with customers, so we can deliver the future together as a team.

Microsoft work hard to embrace Microsoft Dynamics CRM partners and help enable them to sell Microsoft Dynamics CRM (although perhaps more focused on larger partners and enterprise solutions).  The training materials Microsoft offer is pretty good and the Azure training is really good.

Microsoft offer a competitive price for Microsoft Dynamics CRM Online.

Internally hiring the best people who want to make a difference.  Under Satya Microsoft have started to innovate rather than copy.   This outlook should be brought to the Microsoft Dynamics CRM division to create innovative new functionality and have a workforce engaged to deliver it.

Hosk’s Dynamic CRM Practise

How would I answer those questions with my virtual Hosk’s Dynamic CRM Practise and what strategy would I come up with.

1 – What is the future we want want and how great can we be?

When implementing CRM solutions I find lots of cautious companies who wary about signing up for the project due to earlier bad experiences with IT projects and failed CRM projects.  There are many companies who have lost confidence in their existing Microsoft Dynamics CRM supplier.

Microsoft Dynamics CRM companies don’t sell products they sell people, processes, technical knowledge and experience (I know companies who create products).

The future  vision is to create a reputation for being an innovative company delivery quality projects, collaborating with the customer.  You want your CRM company to be the best in their sector and who put quality and customer satisfaction at the top.

It‘s difficult to differentiate through price alone, focus on being the best choice to deliver CRM projects for the customers requirements with regards to experience, vision and capability (skilled people, resources).

When a customer buys CRM from your company

  • you know the reason,
  • the staff know the reason
  • the customer knows the reason.

To win business you must have strengths which other companies cannot match.  Pick an area of expertise and become the best at it

2- How do we play to win and perform at our best

The future for Microsoft Dynamics CRM practices is to specialise in an industry or technological service.  The Microsoft Dynamics CRM industry is crowded with lots of companies offering similar services and at similar prices.  Ask yourself why would someone buy CRM from my company?

  • price?
  • experience?,
  • an existing solution?

Most successful Microsoft Dynamics CRM resellers and the ones Microsoft have purchased, they focused on a specific area and become the market leader.

FieldOne – The best Field Services company in the Microsoft Dynamics CRM space (the only one I know to be honest).  They were so good Microsoft brought them, which is an indication you are doing something right.

Parature – Fantastic self-service portal, knowledge base, which can run alone and is slowly (very slowly) being integrated with Microsoft Dynamics CRM.

FantasySalesTeam – Microsoft Dynamics CRM and Gamefication (Hosk blog –  Is Gamification in a Microsoft Dynamics CRM a gimic?)

Resco – The leading Microsoft Dynamics mobile application/framework (Hosk blog – Why Resco acquiring CWR’s mobile CRM is important)

My strategies

  • Focus on Microsoft Dynamics Online solutions and specialise in delivering complex Microsoft Dynamics CRM projects online.  Align skills with Microsoft’s vision – Mobile, Cloud (Azure)
  • Concentrate on delivering FieldOne projects.  Field services is a growing marketing with Microsoft Dynamics CRM.
  • Get a head with Azure Machine learning and CRM.
  • Focus on 2 sectors, Create solutions to speed up projects.

3 – How do we build relationships internally and with customers, so we can deliver the future together as a team.

You need leaders, who can create a vision, mission and goals and explain this to the organisation.  Everyone should understand what the company strategy is and it’s goals.

Employees

You need to engage the employees so they will deliver the strategy.  Fully engaged employees not only understand the strategy but add to it with ideas, energy and hard work.  Engaged employees feel valued, listened to and believe they are making a difference, this leads to quality work.

If you think about the difference in amount and quality of work when you were engaged on a project compared to other projects, the difference is huge.

Staff must have the skills/training to deliver projects to high standards, customer satisfaction is vital.  The focus is on quality projects, quality individual performance and constant improvement.  In the Microsoft Dynamics CRM industry you are mostly selling people.  Happy, motivated and engaged in order to deliver great projects.

Team is important in Microsoft Dynamics CRM community, the number of technologies/products and services used in Microsoft Dynamics CRM projects is growing, the team must collaborate, talk, support and share knowledge to deliver quality projects to meet customer expectations and enhance the reputation of the company.

Customers

Great relationships with customers come from delivering projects which meet business requirements and delivered on time.

Conclusion

Writing this article helped me understand I haven’t thought deeply about the subject before and my  thoughts and ideas were other people’s or snippets of articles I had read.   I could see some of original thoughts on the subject emerging but more work is needed to come up with a viable strategy for the Microsoft Dynamics CRM industry.  I’m not sure my Hosk CRM practise would have done particularly well with the strategy outlined above.

It‘s difficult to create strategies without understanding the current Dynamics CRM market, identifying where the Dynamics CRM industry is heading and what opportunities are available.

I hope you found the article interesting, please leave some comments on the subject

If you are interesting in learning more, I recommend these two books

ALL VIEWS AND OPINIONS ARE PERSONAL OPINIONS OF THE HOSK 

Advertisement

CRM 2016 – How to rename the default business unit

Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time. Thomas A. Edison

I came across an annoying bug, I couldn’t rename the Default business unit because the parent business unit is mandatory.

History of default business unit renaming

The renaming of business units is a long and extremely interesting subject…..said no one ever.

The default business unit or parent business is automatically created using the name of your organisation.  In CRM 4 I don’t think you could rename any business units.

In CRM 2011 they allow you to rename business units which were not the default

CRM 2011 – You can rename and delete business units

In CRM 2013 (according to my study notes) you couldn’t rename the default business unit in CRM 2013

CRM 2013 – MB2 703 – Manage user access, Teams and sharing

Another interesting fact

default business unit team cannot be re-parented, deleted or renamed and it’s members cannot be modified.

In CRM 2015 you could rename the default business unit, well it’s possible but Microsoft make it difficult for you to do because the parent business is a mandatory field but if you are editing the default business unit it has no parent business unit, which means you can’t save the record.

CRM 2011 forms?

I tried using God Mode JavaScript shortcut but this didn’t work and I’m guessing this might be because this form is an old school CRM 2011 style form?  What is it doing in CRM 2016!

rename business unit 2

You can see the annoying required Parent Business unit field

Solution

There are a few ways to resolve the problem but the easiest way is to go to

  • Settings –> Customization’s
  • Entities –> Business Unit
  • Open the field – Parent Business – parentbusinessunitid

rename business unit

  • Change the Field Requirement from business required to optional

rename business unit 1

  • Save and publish customisations.
  • Change the name of the Default Business Unit – Save
  • change the Field Requirements of the Parent Business field back to required and publish

Mission accomplished

If at first you don’t succeed, try, try again. Then quit. There’s no point in being a damn fool about it. W. C. Fields

 

How are you going to test the logic of your code

Simple systems are not feasible because they require infinite testing. Norman Ralph Augustine

Developers must be able to isolate and test their code easily and often in their own development environment.  If you don’t test your code you will let more bugs into production environments and this will cost you more time and effort in the long term.

Developers must be proud of their work, be craftsman and create quality code.  Poor quality code is a drop in standards which can spread to multiple developers like a virus – Bad code is like a virus, don’t get infected.  As a team/group you can choose to raise standards and get all members to raise their game or you can let standards drop.

Keep your standards high, your code quality and Never leave a CRM developer stranded

Questions

I get questions from Hsok CRM blog readers asking me to resolve problems they are having or asking for advice.  Below are two good examples

If I could offer some advice about asking questions

  1.  Be polite, say hello, how much you love my blog and then your question 🙂
  2. Investigate the problem yourself first.  Google the problem, try things, ask your friends/colleagues and then if you still have problems ask the problem on the CRM forum
  3. Provide me (and the CRM forum) with as much information about the problem as possible e.g. CRM version, what you are doing and why, what you have tried, the results of your research.  More information = greater chance of someone/me helping you.

I received an email from Martin who had read my blog posts on unit testing with Microsoft Dynamics CRM

Martin was working on writing a webservice and found unit testing was a great way to test the logic of the code without having to deploy the code in the production environment which was tricky.

Isolate the logic of your code

Logic is the beginning of wisdom, not the end. Leonard Nimoy

 

Unit testing is about isolating and testing the logic of your code.  The main benefits of unit testing

  1.  You think about designing and structuring your code to make it easy to test the logic
  2. You and any developers can rerun your tests
  3. It’s easier to refactor the code because you can test it still works.
  4. Developers who unit test, think more about what they are testing

Thinking about what you are doing, questioning how you are designing the code and thinking about what the code is doing helps create better code.

First draft code works but is sloppy and complex with lots of dependencies.  First draft writing, you must edit your work to remove sloppy code and improve the overall code quality.

UNIT TESTING ALLOWS YOU TO EDIT CODE AND BE ABLE TO TEST THE CHANGES

If you haven’t got unit tests, you might break the code and not know about it, unless you test the code and all areas which uses the code.

How do you know the logic works

When a junior developer has written a plugin, web service or piece of code, I always want to know how they have tested the code works.

Before I started writing unit tests, I used to have a console application which connected to the development CRM environment and ran my plugin code.  I could do this because I wrote the plugin code as a separate piece of code which was passed a CRM connection and entity.

If you cannot run through the logic of the code on your own dev environment then you are making it difficult to test.  Difficult tasks are often not done by developers short on time.

Unit tests are the best way to test the code but a console app so you can step through the code is a good second.

 

Martin’s email about the

Use Case for Mocking WebServices

Hi Hosk,

Unit Testing is at first somehow abstract but we had some requirements to use a 3rd party WebService, where Mocking saved us a lot of time.

The WebService-Provided only allowed connection from whitelisted IP’s. Our customer only ordered the smallest Internet Package from his ISP.

Every 24 hours the customer had a new public IP. So we couldn’t get a connection form the cooperate network. Upgrading the ISP-Packing was also impossible.

The Webservice-Provided refused to add the whole ISP-Subnet. Our customer had already an Azure Cloud Service with a reserved (static) IP. So we decided to deploy our Code there.

Deploying and debugging is somewhat unhandy in this scenario. It take approximately 15 Minutes to deploy the Cloud Service and start Debugging.

I decided then to Mock the SOAP-Service so I could easily develop locally. This was a big time saver.

Maybe this Story helps other to understand what you can also address with Unit Tests/Mocking. Another possible Use Case for it is when you only have a production System and don’t wan’t to mess it up or when you must pay for every requets you submit to the 3rd Party WebService.

Why isn’t code reused in Microsoft Dynamic CRM projects?

Microsoft Dynamic CRM code and customizations are rarely reused between projects and few companies create solutions to share between projects. This means CRM companies need to rewrite the same code again for each project but is there an alternative method.

CRM projects focus on delivering solutions but don’t to reuse solution and code.  In many companies CRM developers can create different versions of the same solution.

When developers work on projects they are focused on delivering a solution to meet the customers requirements.  If time the developer will

  • Improve code design
  • Refactor code
  • Reduce technical debt
  • Unit test code
  • Update documentation

The tasks mentioned focus on long term benefits and the reason they are often omitted.  Improving code design and refactoring make code easy to understand, extend, debug and maintain, these steps are unnecessary but make a huge different in maintaining the code.

The difference between good and average CRM developers can’t be seen in functionality delivered to the customer because they will be the same.

This posts

Why your CRM code and customizations should be simple

The problems with complex code and complex CRM Customizations

It’s difficult to simply code, refactor and improve the design, a reason average developers omit those steps.  Explained beautifull by Martin Fowler

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

Martin Fowler

Simple code reduces time spent debugging, maintaining, understanding and interacting with the code e.g. further phases of development.  This explains why failures in CRM projects often occur after the first release of a CRM solution when the CRM developers struggle with a messy solution.

Other signs you CRM project is doomed can be found in this article 13 signs your CRM project is doomed

I have worked on a project where a plugin had a method which was over 1000 lines long.  This method became a bottleneck in the project because developers struggled to understand what it did or how it worked.  Small changes took hours whilst developers tried to understand the code, work out where to put their fix and testing the fix hadn’t broken existing code was impossible because the code was to complex to unit test.

Custom code

Most CRM projects will have custom entities which exist only in the individual project to either make the customers business processes or needed to deliver the required functionality.

Writing bespoke projects often preclude the project code and customizations being reused because the customers requirements are not needed in other projects.

CRM developers who don’t use solid principles to reduce coupling in their code are unlikely to be able to reuse code.

Code cannot always be be reused because of unique requirements, most of the time CRM developers don’t think about reusing the code or writing it to enable reuse.

New project, new code

Before software can be reusable it first has to be usable.”
– Ralph Johnson (computer scientist)

Reusing code is a great, you can add code which has already been written and tested.  It takes more effort to write reusable code, to write code in a generic way ensuring there are no dependencies on the current project.

Developers are not rewarded for code reuse or encouraged to write reusable code and customization’s by their employers.  Without motivation or reward why would developers go to the extra effort of writing code which benefits developers/company in the long term?

To write of reusable code you need skilled developers, sometimes called craftsman.  Highly skilled developers, take pride in their work and consider long-term implications of their code and who look to reuse code.

Most CRM projects are run with short-term goals in mind, answer these questions about Microsoft Dynamics CRM projects you have worked on?

  • How often do CRM developers reuse code from earlier projects?
  • Do CRM developers know what earlier projects did to understand if any of the code or customizations could be reused?
  • How many projects is the code good enough to be reused?
  • Does anyone look at previous projects to see if they could create a generic reusable project?

Companies don’t reuse code or catalog CRM projects.  CRM professions and CRM developers move companies often, most existing and new developers didn’t work on earlier projects and are ignorant of them.

Interaction with historic projects usually occurs when a bug is raised or through a change request.  If you are unluckily enough to be dragged into an old project, they are legacy projects with code and customizations arranged in a baffling structure taking days to decipher even the simplest of bugs.

Is there another way?

Wouldn’t it be great if new CRM projects were created by plugging together small separate solutions.  It would be quicker to create solutions like this and the code would have already been tested.

CRM developers could look at old projects for common functionality that could be reused in different projects.

Identifying functionality which could converted into a generic reusable solutionIf the solution was useful it could be sold but at a least it could speed up development on new projects needing that functionality.

This would involve taking a long term view of CRM development and ensuring their CRM developers are writing quality code and customizations.

Why doesn’t code get reused

Code reuse has many advantages but I haven’t seen any examples of code reuse in the projects I have worked on. I have listed some potential reasons for this below

Developers

A lot of developers don’t love writing code and to them it’s just a job, this shows in the quality of their code.  They are not passionate about it and certainly wouldn’t classify themselves as craftsman.  I don’t enjoy decorating, I take shortcuts and aim to paint a room as fast as possible.  The lack of enthusiasm and passion for decorating the room, shows in the finished product, I spot bits I missed and drip marks.

The same result can happens with the code of people who don’t enjoy developing,

To write simple code you will have need to want to improve, the best way is to have a mentor but you can get a paper/electronic mentor by reading classic books on programming or have a mentor to teach you.  I recommend

CRM companies have s high churn rate, offering small payment increases to staff based on their current salary.  LinkedIn pressures this model with recruitment agencies offering CRM professionals the current market rate for their skills and experience, more than the current salary plus inflation.

The regular movement of CRM developers leads to a lack of long term thinking and planning.  Why write code with long term benefit if you are not going to be there to gain from it.

Development standards and way of working need a consistent workforce to implement and developers adhere to them.

Project view

CRM solution providers organise effort at a project level, gearing everything around projects.   The approach is understandable because customers pay for projects and effort is focused on money.

Creating reusable code and solutions is an activity which needs to be done around or outside of delivering a project.  It may involve going back and identifying reusable/generic solutions or taking a little bit longer to write reusable code.

Maturity of Microsoft Dynamics CRM

I’m not sure about this but I wonder if creating reusable code/solutions is something which will occur with maturity of companies and developers.

Will companies get tired of recreating everything on each project?

Versions

Microsoft Dynamics CRM currently has a major release every year, this adds a significant challenge to creating reusable solutions and code.

A solution created today could become standard functionality in the next release of Microsoft Dynamics CRM or your solution might not work, with a need to upgrade the solution to be compatible with the new versions of Microsoft Dynamics CRM.

Microsoft Dynamics CRM online is increasing in popularity, CRM online projects use a different architecture than CRM on premise.  This provides a barrier to reusable CRM on premise solutions because those solutions won’t work with the limitations of CRM online.

The long term view I have is CRM providers will create micro services in azure which will integrate with CRM online services, this architecture allows one service to be used on many CRM Online projects.  This architecture model is being used by FieldOne and their autorouting service, which is hosted in Azure.

Size of CRM companies

Small CRM solution providers whose model doesn’t afford to spend time on non project work.  Bigger companies should have an advantage over smaller companies by creating resusable code and solutions but I’m not sure many larger CRM companies do this at the moment.

Summary

It’s easy to point out the problem of lack of code reuse, it’s harder to pinpoint the steps to overcome this.

The CRM project mentality creates project focused code, not reusable or often known about by other developers in a company.

FieldOne – Quick way to add Territories for the UK

Territories play are an important part in FieldOne and to understand the functionality provided by FieldOne you will need to setup territories.

Why do you need Territories

Once you have setup territories you can then use them with your resources at set their location.  The location information is used in

  • Work Orders
  • Scheduling assistant and routing engine
  • Filters on the Schedule board

Once you have Territories setup, you can add locations to your resources and work orders.  You can then schedule resources near to the work orders by searching or FieldOne can help you do this by automatically routing using the routing engine or the Scheduling assistant.

Understanding

“In theory, theory and practice are the same. In practice, they are not.”
― Anonymous

 

I recommend CRM developers add theory to the practical knowledge, which is Why CRM Developers should always start with the CRM SDK.

To get full understanding of something you need theoretical knowledge and practical knowledge, this will allow you to find the limitations and functionality of something.

FieldOne is a great example of this because it’s not really until you start to actively use the system by setting up a demo environment or put in customers data until you really begin to understand how it works.  I call this active learning and it’s where the knowledge and practical experience come together to start creating a solution.

List of Territories

The territory on resources specify which area(s) the resource can be allocated work from.

The first step is you want to download some territories, I have found a list of cities

https://github.com/Gibbs/UK-Postcodes/blob/master/postcodes.csv

postcodes csv

You can see the postcodes have geocode details but in this case I’m not going to use them.

Territory

I now have a data to create some territories, I copy the postcodes csv to a new tab/csv, I deleted all the columns expect region and renamed this  Territory Name.  I selected Remove Duplicates so I had one row for each region, I save the file as Territory.csv

Territory

Territory postcodes

FieldOne can match partial postcodes, so if you add the postcode B32 it will match all B32 postcodes. To link postcodes to a territory you need to import into the entity called Zip Codes.  I used the original postcodes.csv and deleted all the fields except region and postcode and named the region Territory Name.  I saved the file as Territory Postcodes.csv

Territory postocde

Import the file using Import Wizard and select the entity Zip Code

Zip code import mapping

Next step

Zip code import

You will end up with 2700 territory postcodes

Next steps

You now have territories in CRM, the next logical step would be to create resources and then import a territory resource to the resource.

This sets up the territory where the resource can be scheduled for when using auto routing or the resource scheduler, if you do manual scheduling you can select any resource but you would probably filter by resource territory.

Below you can see I created some resources called

Birmingham Depot Truck Driver Test001 (to Test011) and created a service territory of Birmingham.  These trucks can be scheduled for Birmingham jobs

Birmingham Truck driver territory

It’s a quick way to get territories into FieldOne, it’s more likely individual clients will have set territories and the data above won’t be specific for your customers.

The steps above will help you get some default territories in FieldOne so you can start to see how territories and scheduling work.

 

 

CRM 2015 – Best practices for CRM Deployments

“Is life not a thousand times too short for us to bore ourselves?”
Friedrich Nietzsche

With boring repetitive CRM Developer tasks  – share the pain, share the knowledge – Hosk

 

Live deployments of customizations are tedious, stressful and critical events for CRM Developers.  Often done outside of hours to avoid disrupting the users (what about the CRM Dev’s, they have lives too!), if they go well it’s as it should be, if something goes wrong the lightbulbs are swapped to read and end users can be heard shouting SHOW STOPPER.

Despite the importance of production deployments not much time is spent thinking and improving the process, it’s often delegating to someone at the start of the project and they are left to get on with it.  In the article below I look at the different aspects of the production deployment and highlight parts to improve.

Solution Overview

CRM developers need to know solutions inside out, upside down and back to front.  Solultions organise and move customizations between CRM environments but be warned, they can cause problems during importing.  When problems occur importing a solution, knowledge of solutions will help you diagnose and resolve the problem.  It’s important you have a deep knowledge of the CRM SDK and why I am often saying Why CRM Developers should always start with the CRM SDK 

CRM developers need a good knowledge of solutions because solutions are a tool you will use regularly, you need to understand

  • What customizations are included in the solution file
  • what customizations are excluded from the solution file
  • working with multiple solutions
  • Which customizations persist when mutiple solutions contain the same entity
  • What the default solution is and how it works
  • The difference between unmanaged and managed solutions
  • When to use manage or unmanaged solutions
  • dependant components
  • common solution importing problems

CRM production deployments are often done out side of hours because importing a solution can freeze Microsoft Dynamics CRM but did you know you can import a solution asynchronisly using the CRM SDK – Asynchronous Solution Import

All CRM developers should have read CRM SDK Introduction to solutions

I have written a brief summary of the CRM SDK solution content in the article Understanding Solutions and how they work

Solutions use guids and sometimes solutions can get out of sync, this article explains how I got into and out of such a mess

Managed solution problems with out of sync solutions

Solution import Errors

Patching solutions

Solutions package CRM customizations, CRM 2016 has improved solutions to allow patching solutions, which allows you to import a smaller range of customizations instead of the whole entity and related customizations

read articles on patching solutions

Whether you are importing an older full solution or a patch solution, the solution is often only a small subset of the customizations being deployed.
Manual deployment steps
CRM deployments can include multiple manual steps, you should consider what manual steps need to be deployed in each deployment, list them out and practise them
  • Unregistering plugins
  • Workflows to deactivate
  • Data to import
  • Security roles to configure
  • Configuration settings to update
  • Workflows to re-point (workflows using data in the CRM instance, which changes guids between organisations)
  • App pool settings to change
  • update WCF dll‘s and config files
  • update GAC dll‘s (if you have deployed any)

Unregistering plugins is a manual step because solutions are additive, which is a fancy way for saying they don’t remove or delete customizations from a target CRM instance.  Some plugins will need to be deactivated manually, usually using the Plugin registration tool.

Workflow re-pointing happens when a CRM records are used in the logic of the workflow.  CRM records will have an inidividual guid, which is assigned to it on creation of the record.  A record could have the same name in different CRM environments but will have different guids e.g. an Account named Hosk in DEV and PREPRODUCTION will have the same name but different guids.  Workflows use lookup (EntityReference) which has the name of the entity and guid to uniquely identify the record.

Workflows which use CRM records will become unpublished when imported into a new CRM environment because the record guid can’t be found because it doesn’t exist.  The manual workaround for this process is to open the workflow and lookup the correct CRM record and this is what I call Workflow re-pointing.

Solution Configuration

The structure of a solution can minimize the number of  customization’s included in a solution and the potential problems when importing the solution.

A solution with all customization’s could grow when customization’s are added, taking longer and longer to import and maintain.

You can split up the solution to reduce the customization’s changed and deployed.

Two common methods of organizing the Solution file are

Release

You can organise solutions to releases/phases/sprints, including the changes for each major release of functionality.  During development it’s easy for developers to work with the solution.  Developers with experience of the project will find release/sprint solutions easy to understand but new developers won’t find the solution content obvious.

The release solution can lead to many solution files because solutions are not reused but it can stop solution files becoming to large.

  • Release 2.1.1.1
  • Release 2.2.1.4
  • Release 3.1.1.0

Customization’s by type

I have seen a few projects organise solution files by type of customization’s
  • Entities
    • Entities and fields
    • Lists
    • Forms
  • Code
    • Javascript
    • Plugins
    • Workflows
    • Custom workflows
  • Reports

Its easy to create visual studio projects containing similar types of customization’s and it’s straightforward for developers touse.

Over time solution files can grow to be big, this can cause problems with several developers changing the same customization, an example is discussed

How do multiple developers work on a web resource within the CRM environment

There is no right or wrong way to structure a CRM solution, it depends on the project, number of customization’s, number of developers, etc.  You need to create a solution organisation method which is logical and easily understood to the developers working on the project.

Document the deployment process

We create CRM development best practices and standards to ensure CRM development is created in standard way and to the required standard.  All the code/customizations should be similar despite being created by different developers.

The deployment process should be documented and processes created to ensure deployments are done sequently, in the same way by different CRM developers.  The benefit of documenting the deployment is transferring the build knowledge out of an individuals head and into a document other developers can follow.

  • The benefit of documenting the deployment process
  • deployment knowledge is shared
  • steps are not forgotten/missed
  • manual processes are documented

A standard deployment document, to act as a checklists to tick off during the deployment.

Pilots have a checklist when landing.  Pilots are skilled individuals often with thousands of hours experience but without a checklist even experienced professionals can forget a step when the pressure is on.

The Checklist Manifesto: How To Get Things Right

During the pressure of a deployment, it’s easy to miss a deployment step, documentation and checklists will help you avoid this.  Checklists and documentation can help do the deployment in the correct sequence (which might be important).

Don’t leave it to one person

Deploying to a production environment is a dichotomy, it’s a group of simple (and usually boring) tasks but it’s important it goes without problems.  Problems with deployments will affect end users and  impact the customer/developer relationship

When one person is tasked with doing deployments they get the deployment process down to a fine art and becomes a slick deploying machine.  The downside is you have created a deployment dependency and no one else knows how to deploy or is confident to do it.  There is pressure on the deployer moving project and when they go on holiday.

Deploying is a boring task which should be shared out between developers, minimum you should have at least two CRM developers who are comfortable deploying customizations in the production environment.

Don’t use personal users accounts

It’s good practice have a general service account to deploy CRM.  This allows anyone to log onto the production environment with a user account who has the required security roles and access to the server.

If the deploying account is a specific user, when someone else logs in to deploy the solution, their user might not have the required security privileges.

Importing the solution is linked to an individual user, the user won’t want to share their user password details.  A big problem can occur if individual users are not in the office and you don’t use a generic service account, you can’t do a deployment!

Backups

Rule 1.  BACK UP everything, no arguments, no excuses, just do it because if it goes wrong and you can’t roll it back the person deploying will be responsible.

A live CRM instance should have multiple backup strategies such as long term backup strategy, weekly and disaster recovery.

Production deployments needs a short term backup strategy, only used if when a problem is identified during deployment and you need to roll back the changes to leave the CRM and related components in the same state pre deployment.

Make sure you are able to roll back all data changes/config changes.

for on-premise it‘s not only the database(s) which needs to be backed up

  • Configs
  • WCF services
  • Windows applications (often running as services)

What to backup? consider different components and data

  • Databases (CRM, Config, External)
  • files on the CRM Server
  • Data on other services (Sharepoint etc)

Data and SQL stored procedures are kept on a separate database, this best practice.  It seems like added complexity but it’s separates the solutions custom tables and stored procedures from the CRM databases, meaning it won’t stop working when a CRM update/upgrade is applied.

Practice restoring

If you ask CRM Developers if they know how to rollback the changes they will say yes, you restore the database blah blah blah.

If you ask the same CRM developers to do it, they will suddenly look worried.  Most CRM developers haven’t rolled back changes.

The last place you want to learn how to restore a database or roll back solution changes is on a live production deployment.

Practice rolling back changes so if you need to do it, you can.

Data

Guids and data can be a headache, if you import the data on each environment the guids will have different guids.  Data used in workflows will break when you move them between environments.  Deploying workflows can be a long arduous job if you have to re point imported workflows referencing CRM records.

A better method is to ensure the guids of your data are the same in all CRM environments.  You can do this by importing data and specifying the guids, this can be done 3 ways 

Manual Method

Exporting the data out of your DEV CRM (ticking for reimport), turning the files into CSV files, this will have the guid each row.  You can import these into different CRM instances

Create a CRM SDK Console app

You can create a console app to export data out of your DEV CRM into XML or CSV.  Code the console app to import data specifying the guids

Use a Tool – CRM Configuration Data Mover

CRM tool wizard Lucas Alexander has created a CRM configuration Data mover to move the data and keep the guids.  He has written a great blog post to step you through using it

Introducing the Alexander Development Dynamics CRM Configuration Data Mover

Release notes

Creating a release note is a pain, it’s a boring manual job but…. they are very useful.
  • Customer knows what is being imported
  • You have an audit of production deployments (data, list of customization’s)
  • You can see what bugs have been fixed and when
If you put your bugs into TFS you should be able to create release notes by creating a view and exporting.  Like all boring jobs, automate the process and where you can and share the task between developers (e.g. share the pain and the knowledge)

Solutions

Solutions have version numbers, use them.  Don’t deploy customizations without changing the version number.

It’s frustrating and confusing when CRM developers update customization but don’t change version numbers.  This works OK in dev environments but when you have 3 or 4 CRM instances hosted on customer servers it makes it impossible to know what has been deployed.

Solutions have a description, you can use this to add more information about what was released.

Automate

If your deployment has manual steps which need to be done every time or often then automate those steps.

You can use simple bat files to copy files to the correct location and restart IIS, CRM Services. install DLL’s into the GAC, etc.

The danger of repetitive and boring tasks is they can be easily missed.  I worked on a CRM deployment which had 11 CRM servers.  The build process involved installing DLL’s to the GAC, updating solutions, updating Windows services and often importing data.  When doing this repetitive task you enter a zombie like state

clicking, copying, clicking, copying, restarting

The process was boring and took two hours to do a simple deployment.  I created bat files to copy files to the servers.  A bat file on each server, deployed DLL’s and restarted ISS, restarted CRM services.

The benefits were two fold

  • all dll‘s were all deployed and all services restarted
  • The deployment took half the time
  • The deployment wasn’t as boring

I’m sure there were better ways to automate the build but to create the bat files was simple and made the deployments less of a pain for me.

If you can automate parts of the build, do it because automating will avoid mistakes, take less time and isn’t as boring for the person deploying.

Plan and Preparation

On one project one deployment was a whopper, twice as big as the average deployment.

The deployment would take 4 hours but the size of the deployment cause us to plan the deployment in more detail and we were more prepared.  We deployed in 3 hours and it was the smoothest deployment we had done on the project.

Time spent on deployment preparation leads to smoother deployments, make sure you are given adequate time to plan and prepare for the deployment

Pair deployment

You rarely need two people to deploy customization to production but having two developers doing the deployment has advantages

  • It’s quicker with two people
  • reduces mistakes
  • Less likely to miss steps
  • Not as boring with a buddy
  • Deployment knowledge is shared

Two people will ease the pressure and work on a single person deploying.  It’s keeps both people focused during the deployment.  If the deployment goes wrong during the deployment, two heads are better than one.

Summary

This post was meant to be a small post to highlight a few observations I made during a successful production deployment.  The more I though about production deployments the more parts to a successful deployment process I found.

What I found unusual was the lack of time spent on improving production deployments and ensuring they are efficient.

Automating as much of a deployment as possible should be priority because deploying customization’s takes lot of time and there are usually at least four CRM environments to deploy to.

 

How do multiple developers work on a web resource within the CRM environment

“Alone we can do so little, together we can do so much.” –Helen Keller

 

“None of us is as smart as all of us.” –Ken Blanchard

 

I get asked questions from readers of the blog about general CRM topics such as career advice, finding a job, creating plugins or help with a specific problems/errors.

Ask the Hosk questions

If you are going to ask me a question please be polite, it will increase your chances of me answering your question, don’t forget to say how much you like my blog (that really increases your chances of getting an answer).

Take into account I’m a busy Hosk, I work, I have 2 young children, a wife and sometimes even get to chill out or play football.  Sometimes I could be too busy to answer your question quickly.

I won’t always know the answer to your question, if I haven’t read about a topic or got any experience in the topic I can’t give a good answer.

The CRM Forum

Instead of asking individuals a question I would recommend raising a question in the CRM Forum, for these reasons.

  • It’s free
  • CRM MVP’s answer many questions
  • CRM experts who have experience will answer the question
  • Microsoft CRM support answer questions
  • You might get a number of answers and opinions

A bonus reason to raise the question on the forum is after you have raised the question on the CRM forum, you can email me and ask me to look at the question.

CRM forum

When you raise a question, try to give as much information as possible, this will help anyone who answers your question.

The CRM forums are a great way to learn CRM, you can see common questions raised by CRM users and the answers from CRM experts.  I answered over 400 forums questions and learnt a lot and helped users in the CRM community.

Question

How do multiple developers work on a web resource within the CRM environment?

With traditional web development if there are multiple developers working on the same page then they will each have local copies/websites to develop and test against then merge the changes in source control.

However, CRM web resources usually rely on the XRM SDK and the parent window within the CRM Evironment.

Are there any best practices for being able to have multiple developers work on the same web resource simultaneously?

 

Answer

This is a great question, working with a team of developers can be frustrating when they overwrite your changes, this didn’t quite make it to my list of frustrations of a CRM developer.

It’s a common scenario, particularly on big CRM projects and part of the problem lies with communication and practices

In the book The Mythical Man-month: Essays on Software Engineering the author Brookes discusses why adding more resources doesn’t always speed a project up, a great quote Brooks law

Communication overheads increase as the number of people increases. Due to combinatorial explosion, the number of different communication channels increases rapidly with the number of people.[3] Everyone working on the same task needs to keep in sync, so as more people are added they spend more time trying to find out what everyone else is doing.

 

Communication is key to successfully working with a group of developers, particularly if you are working on a shared environment.

Encourage developers to communicate via talking face to face, phone or instant messaging.

Multiple developers can develop separate parts of a CRM solution.  There will be time when development will overlap.  The quickest technique is to talk and work together, there are some steps to work without overwriting each others changes but this will involve some code merging will can be painful.

Important

If two developers have worked on the same customization, it’s important you test all new functionality to ensure the last modification hasn’t affected the previous modification.

Source Control

Whether you use TFS or something doesn’t matter but what it is important is everyone checks in their code regularly.

Get into a habit of checking in code regularly, at minimum

  • Get the latest code in the morning before starting code
  • Before you are about to change some code, get latest
  • Check in code before you leave

Source control can be a pain, but it will save you skin on many occasions, don’t fight it, embrace it.  The more you refresh and check in your code the less likely you are to suffer merge hell.

Development Environment

Most CRM Development environments are a CRM server hosting a development CRM instance.  Multiple developers access and develop CRM customizations on it.  This lead to some problems if developers were working on the same Javascript file.

Developers will usually be working on separate plugins/Javascript, which avoid conflict and overlapping/overwriting code.

If two developers need to work on the same plugin, you can create and test the code in a separate class, avoiding conflict and merging later.

It’s possible to have separate VM’s on individuals laptops, so each developer has their own separate CRM Instance.  This is possible but the majority of CRM development projects I have not worked with this setup.

Unit Testing

Unit tests allow developers to isolate the business logic by faking/mocking interactions with CRM.  Writing unit tests allows the CRM developer to test their code on their local machine without any dependency on the CRM developer environment.

With unit tests, multiple developers can work on CRM customizations without affecting each other.

No right answer

This question is tricky and I don’t have a right answer or the perfect way for a team of developers working together without stepping on each others toes.

Source control is an important tool for a CRM developer and not just for teams working with multiple developers on the same project. It’s a vital tool which gives an audit trail of the code and saves the code safely in a repository which acts as a disaster recovery for your code on a developer’s laptop.

Source control will help recover overridden code, but it’s unlikely to stop developers overwriting code.  The most effective method is for different developers to work on separate customizations or give allocate only one developer to work on a single customization.

If multiple developers must work on the same customization then communicate with each other to agree on a way of working

 

 

CRM 2015 – How to set focus in Javascript

I wanted to set focus in Javascript after a user had changed a field to yes, this triggered an onchange event.  The onChange event set a new tab to be visible.

The new tab was below and the users didn’t always know it was there, so I wanted to nudge them in the right direction by setting focus on the tab.

Microsoft has added a great framework for manipulating the controls.  The Javascript for setting focus works on the Control level

Xrm.Page.getControl(arg).setFocus()

Xrm.Page.ui.tabs.get(“tab_schemaName”).setFocus();
Xrm.Page.getControl(“ntt_reviewteamid”).setFocus();

This blog post has a great page, it highlights the functionality available in the CRM SDK, displaying the logical structure of the JavaScript wrapper created for development

Microsoft Dynamics CRM 2013: Client API Enhancement

 

Different Versions

It’s important to check the CRM SDK XRM documentation because each release of CRM adds and removes functions.

Xrm.Page.ui control (client-side reference)

The CRM SDK documentation shows the functionality available for each release by selecting the CRM version in the drop down at the top of the page.

Javascript versions

When you select a different version it will change the methods available.  This enables you to see what functionality is available for each version and what new functionality has been added.

CRM 2013 – Remote Debugging

Only those who dare to fail greatly can ever achieve greatly.”

― Robert F. Kennedy

Developer fear

When I was a junior CRM Developer I couldn’t get remote debugging working, Visual studio wouldn’t attach, port problems etc.  I gave up because I need to resolve the problem.

Until I have done something I’m not sure I can get it working.

The mind makes unknowns scarier; it exaggerates and focuses on worse case scenario’s. Like visiting somewhere you have never been before such as you first day at school/university.  The location seems bigger and shrinks in size with familiarity.

Remote debugging is frustrating because to find out why a customization is erroring you need to debug it.

One day I came to work determined to get remote debugging working and after half a day of trying I got it working.

When using a tool or functionality for the first time, you are outside of your comfort zone (How to cope when you are out of your Developer comfort zone)

Why we need a CRM Developer toolkit

It’s important the CRM developer toolkit is updated and works with CRM 2015/Visual studio 2015.  The CRM developer toolkit makes it easier new CRM developers to write, update and deploy plug-ins.  We don’t want barriers for new CRM developers we want to encourage them to join the CRM development community.

Remote debugging considerations

Remote debugging has some drawbacks, if the plugins has isolation mode = “none” you use the CRM async service, W3p.exe.  This stops the CRM server  processing system jobs, other users have to wait until you have finished debugging.  This is frustrating for other developers because it stops them using CRM.

A better alternative is to test your code using unit tests or console app if I want to call it with data in CRM, this has no effect on other developers and units tests can be rerun by any developer.

Most scenario’s you can test your logic without using the remote debugger, Why CRM Developers should unit test their code

I wrote about remote debugging for CRM 2011 before

CRM 2011 – how to set up Remote debugging for plugins

If you experience problems setting up the remote debugger, try this blog

Remote Debugging CRM 2011 Plugin

Learn Remote debugging before you need it

It’s better to learn a process, new functionality before you use it for the first time on a project,

Make mistakes in practice, it’s a less stressful place to learn than on a live project

Get experience remote debugging before you need to use it.

Remote debugging can be a frustrating due to difficulties in setup and configuration.

Remote debugging is on for On Premise CRM only

You cannot remote debug CRM online.

To debug plugins deployed on CRM Online, you have these choices

The purpose of remote debugging is to test the logic.  You can recreate the scenario from in dev by recreating the data.  Remote debugging shouldn’t be the first tool when diagnosing a problem, it can affect performance and other developers

  • Unit Test
  • Console app and Test plugin code
  • Plugin Registration tool

The debugging option work with CRM On Premise but you cannot use the remote debugger with CRM online.

You can unit test code and create a connection for IOrganisationService to your online CRM and pass and then run unit tests.

Console App

Create a console application, connect to your CRM online and test the code, mimicking the plugin.

Plugin Registration tool

The plugin registration tool can debug the code, it has the advantage of not freezing the whole server because it works with CRM on premise and CRM online.

This video has a good walkthrough of the process Debug CRM Online Plugins

CRM 2015 has added plugin tracing, read more about it here and here

Remote debugging steps

The process is the same for CRM 2011, CRM 2013 and CRM 2015 plugins.  Custom Workflows are different, this blog post walks through the process – Debugging Workflow Custom Activities with Plugin Registration Tool

In this blog post I focus on using the remote debugger and a plugin

I’m using CRM Developer toolkit and running the remote debugger, you can run it as a service which runs all the time (called Remote Debugger) or you can run it as application. which starts when you need it.

Running as a service is it’s always running and can be set to auto start on server reboots.

The downside is the remote debugger service will always be running and taking a bit of server memory/processing (although not much).  You can stop the service if you need.

Developers should use remote debugging in a development environment.

Build the plugin

Copy the plugin/custom workflow .dll and .PDB files to the CRM server directory

C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly

If you haven’t installed CRM on the C drive then you need to look for it on another drive

The DLL’s and PDB copied to the server must contain the code you want to debug in Visual Studio.  If the code on your local machine is different from the deployed plugin you won’t be able to debug

Important – Copy the .dll and .PDB files to C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly

Important 2 – Any dependencies in your plugins (dll‘swhich are not in the GAC need to be copied to the server as well.

I copied the PDB files here

C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly

What is a PDB file?

You may be wondering what a PDB file is, my knowledge of them is you need them for debugging and they contain the code you have written where as the DLL has the compiled code. 

Wiki describes PDB file as

http://en.wikipedia.org/wiki/Program_database

PDB stands for Program Database, a proprietary file format (developed by Microsoft) for storing debugging information about a program (or, commonly, program modules such as a DLL or EXE). PDB files commonly have a .pdb extension. A PDB file is typically created from source files during compilation. It stores a list of all symbols in a module with their addresses and possibly the name of the file and the line on which the symbol was declared. This symbol information is not stored in the module itself, because it takes up a lot of space.

A PDB is needed for debugging, it isn’t needed when you deploy your plugins or custom workflows.

recap of steps

  • Ensure the remote debugger is running as a service or application
  • Build the plugin
  • Deploy the plugin
  • copy the DLL and PDB to the CRM server folder
  • C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly

Attaching the process

You should be ready to attach Visual Studio to the process and wait for the code to be trigger and your visual studio breakpoint to be hit.

Set a breakpoint in the plugin, put the breakpoint at one of the first lines to avoid breakpoints not being hit because their code was either erroring or not being triggered.

Press the Attach button

remote debugger attach

Brings up this page, it will default to your local machine but you need to put in the name of the CRM server and the port used in the remote debugger.

If my port was 4016 and the CRM server was called CRM server.

CRM Server:4016

Remote Debugging 3

Make sure you tick Show Processes from all users, if you don’t you won’t be able to see the CRM services because  they are most likely run as a different user.

If you don’t know your port number, you can go to the CRM server, open the Remote Debugger to find the path of the application

Remote Debugging 1

click on msvsmon and it will error and tell you the port number you are using.

Remote Debugging 2

When you put in the correct CRM server and port number, the services running will be listed.

If you plugins are in the sandbox (Understanding Plugin sandbox mode) you need to attach the to the process Microsoft.CRM.Sandbox.WorkerProcess.

remote debugging

Usually there are multiple Microsoft.CRM.Sandbox.WorkerProcess. This is because you get one for each CRM web page.  It’s difficult to work out which process is the process you want to debug, so I usually select all of the Sandbox WorkerProcesses to ensure I debug my process.

The final stage is to trigger the plugin and debug your plugin.

Good luck

CRM 2015 – What developers need to know about the activity entity

Microsoft Dynamics CRM has different Activity entities, showing actions from the CRM users.  ActivityPointer records are automatically created when an Activity record is created, enabling developer to retrieve different Activity types with one request.

If you don’t understand how to use the ActivityPointer record you can quickly get bogged down trying to retrieve individual Activity types.

CRM developers should think in entities when designing CRM solutions, activities track the activity and effort of the people using the CRM Solution.

Activities are the actions users do in CRM, often tracking the interaction between users and customers.

CRM has lots of different activities

  • PhoneCall
  • Task
  • Letter
  • Email
  • Appointment
  • Fax
  • Custom Activities

Tracking the activity of users/customers, records the time spent on CRM records. For cases, you can see activities associated with the case.   Tracking activities allows different people to work a record with a full knowledge of the status of the case.

Activity facts

  1. Activity is an entity in CRM, you can look at it in the custom solution
  2. The activity entity is non-editable.
  3. Activity schema name is ActivityPointer e.g ActivityPointer = Activity
  4. ActivityPointer is not the same as Activity Party

Microsoft ActivityPointer description

“Task performed, or to be performed, by a user. An activity is any action for which an entry can be made on a calendar.”

What’s the purpose of the Activity Entity?

If you can’t explain it simply, you don’t understand it well enough.

Albert Einstein

To understand a CRM functionality, you need to understand its purpose.   Once you understand what it’s used for, how it works and why it works in that way.

CRM developers should Start with the CRM SDK and then explain it to yourself in your own words.

The purpose of the Activity entity is in the schema name – ActivityPointer.  Developers can retrieve all activities with one request, instead of multiple retrieves using the different activity types.

The activity views allow you to show all activities for a record, despite the activities being different types (e.g. Email, PhoneCall, Task)

The CRM SDK has a great page on Activity entities.

The diagram shows why understanding Activities is important, Activities are linked to the primary entities in CRM.  Activity entity acts like an interface between primary entities and individual activities.

Why do you need to know ActivityPointer?

ActivityPointer is a generic, it holds links to all activities.  You gain the ability to retrieve all Activities but lose the ability to retrieve individual fields or custom fields on the different Activities.

The alternative would be to have a Sub-grid for each different activity type!

activitypointer views

The ActivityPointer is a wrapper or interface to all activities, it includes the generic fields found on all activities.  Microsoft ensures activities have common fields by making you tick the activity checkbox when creating an activity entity.

ActivityPointer.ActivityId

ActivityPointer.ActivityId will have the same value as the Activity its wrapping.  Using the example of an Email activity.

Email.ActivityId will have the same value as the ActivityPointer.ActivityId

activitypointer view

activity pointer email fetchxml

Doing an advanced find for Activities, when you click on an Activity record it will open the Activity, e.g. click on Activity record of type email, it will open the email.

ActivityId’s are the same because an Activity record is created by CRM when an activity record (Task/PhoneCall/Email/etc) is created.

Activity Types

Doing an advanced find, you can use the Activity Type field on the ActivityPointer entity to see what Activites types can be ActivityPointer records.  The Activity Type is a Global option set

activity type

Activity Type – activitypointer_activitytypecode

activity type 1

IsRegularActivity?

There are lots of activity types which don’t look like regular activities, such as

  • Bulk Operation
  • Case Resolution
  • Opportunity Close

CRM creates activities when a Case/Opportunity is closed but why don’t these activities appear in the Activity views?

The field IsRegularActivity on the ActivityPointer entity is set to no for CRM created Activities.

If you search for all Activities you can view the non-regular activities, I mainly had Case Resolutions

activitypointer

Custom Activities

When creating a custom entity you can specify if the entity is an activity by checking Define as an Activity entity

activity checkbox

I have discussed this in detail in this blog post below

CRM 2013 – When should you create a custom activity entity?

Think about the security limitations of creating Custom Activities, e.g. Any security settings will be applied to all activities. It’s unlikely you want any security on activities because most users need to read and create activities.

Important facts to remember when creating Custom Activities

  • Custom Entities when created by default are not viewable/usable to any users apart from System Administrator and System customizer roles. Other security roles will have to add the entity (don’t forget)
  • If an entity is selected as an Activity this cannot be undone
  • Custom Activity entities are available to users who have access to other Activity entities

I have worked on a project where security concerns meant the custom Activity was converted to a standard entity. We created a custom entity (Which you can apply security too), copied the data into your new entity, deleting the custom Activity.

Activity and SQL

ActivityPointer entity has an SQL table and Filtered view () created on the CRM database.

  • Table – ActivityPointerBase
  • Filter – ActivityPointer

Tables in the CRM database allows you to create reports using Activities.  Best practise is to use the ActivityPointer filter,  why filtered views are useful

The blog post does an excellent job explaining Activity entity with SQL.

All About Activity Entity Query Full Guidance in CRM 2011/2013 : Basic–Complex (ActivityPointer, ActivityParty) Queries in One Post

Activity coding problem

I needed to reactivate a case and reactivate the last Activity for the case.

The existing code activated Tasks but now I needed to activate Tasks and PhoneCalls.

Developer assumptions cause many bugs.  Functionality should work how the user wants it to work, not the developer, remember You are not the end user

I needed to check all the activities for the case and reactivate the last PhoneCall or Task activity.  Task and PhoneCall had a custom field which indicated if the Activity should be reactivated.

The custom field increased the complexity, ActivityPointer record doesn’t contain the custom field because ActivityPointer contains generic fields common on all Activity records.

My plan

  • Retrieve all the Activities using ActivityPointer
  • Loop through Activities, checking if the Activity was of type PhoneCall or Task
  • Use Activity.ActivityId to retrieve the Activity

Here is Linq query I used to retrieve ActivityPointer


        public List<ActivityPointer> GetRecentActivityForIncident(Guid incidentId)
        {
            
            this.tracingService.Trace("Enter Method GetMostRecenActivityForIncident");
            using (OrganizationServiceContext crmContext = new OrganizationServiceContext(this.crmService))
            {
                var mostRecentWrappedTask = (from t in crmContext.CreateQuery<ActivityPointer>()
                    where
                        (t.RegardingObjectId != null && t.RegardingObjectId.Id.Equals(incidentId))
                        && ((int) t.StateCode.Value == (int) TaskState.Completed)
                    orderby t.CreatedOn descending
                    select t);
                return mostRecentWrappedTask.ToList();
            }

        }

After writing this post, there is a simpler solution.  I retrieved all the Activities and had to loop through the list, discarding activities until I got to a Task or PhoneCall.

I could have used the ActivityType filter to retrieve the ActivityPointer records with an ActivityType of PhoneCall and Task.