Sunday 31 May 2015

MissingMethodException Workflow Activation CRM Troubleshooting

Sometimes after we upgrade our CRM version to SP1, we have error when you try to Activate a SLA:

MissingMethodException 
   Method not found: 'Void Microsoft.Xrm.Sdk.Workflow.Activities.StartChildWorkflow.set_InputParameters

(System.Activities.InArgument`1<System.Collections.Generic.Dictionary`2<System.String,System.Object>>)'. at 

Microsoft.Crm.Dialogs.ActivateDialogPage.ConfigureForm() at Microsoft.Crm.Application.Controls.AppUIPage.OnPreRender(EventArgs e) at 

System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean 

includeStagesAfterAsyncPoint)  
   http://172.30.101.6:5555/CRA/_grid/cmds/dlg_activate.aspx?iId={2644DE6B-F006-E511-93FD-00155D64E803}&iIndex=0&iObjType=9750&iTotal=1 
   /CRA/_grid/cmds/dlg_activate.aspx 



Cause:

You have restarted the AsyncService and it won't help.

It is actually caused by your CRM Server still stores the old Microsoft.Xrm.Sdk.Workflow.dll assembly version.

It is different from your dll inside the CRMWeb/bin folder.


If you notice its version is still 6.0.xxx..... while the SP1 should start from 6.1.xxx

Solution:

You have restarted the AsyncService and it won't help.

So, you need to replace the old dll with the new one from your 'C:\Program Files\Microsoft Dynamics CRM\CRMWeb\bin' folder..

If you cannot just copy and paste to overwrite the file, you might need help from gacutil command

At first, please backup first the DLL, just in case something happened after you uninstall it.

Then, please check this one:

gacutil /l Microsoft.Xrm.Sdk.Workflow

If it has no of items = 1, means you can uninstall it, please continue and uninstall it by this command:

gacutil /u Microsoft.Xrm.Sdk.Workflow

Here is the screenshot


To run the GACUtil, you might need refer to this:

https://msdn.microsoft.com/en-us/library/ex0ss12c%28v=vs.110%29.aspx

*If you can't find the gacutil because you have no Visual Studio, you can install the Windows SDK, if not also, do not worry, you do not need all of this, as long as you have installed the .NET Framework (which I am sure all of you have installed it)

Just go to the C:\Program Files <x86>\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools>

> So the sequence commands:

cd  C:\Program Files <x86>\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools>
gacutil /l Microsoft.Xrm.Sdk.Workflow
gacutil /u Microsoft.Xrm.Sdk.Workflow


After you uninstall it, you can copy paste your newer version dll inside its folder

And see that this will save your day

Hope this helps!
Thanks.

CRM 2013 SP1 & CRM 2015: ‘My Organization SLA does not work properly” Troubleshooting Check Points

After we upgrade our CRM 2013 to CRM 2013 SP1 or even CRM 2015, we expect that we will have out of the box functionalities, such as Social Profile, Case Creation Rules, Case Routing Rules, and of course the SLA and Timer things functionality. But how sad we are when we know that some of the functionalities did not work properly.

Based on my experience, I would like to share you tips how to troubleshot and do provide you checklist to help you complete your checking when you face a problem that your SLA never works.

Steps:

1. Please check have you activated the SLA?


2. Do you have any SLA rules differentiated by customers? If yes, then you should configure the Entitlement



3. You dont have any Entitlement or special treatment for your support level? Then, make sure you have chosen one of your SLA as the Default one, then the system will use that rule for every customer.



4. If you ever deactivate the SLA and wish to re-activate again, do not forget to ‘Set As Default’ once again.

5. You did everything, but you are not sure whether this works or not. Please go check the System Jobs, CRM basically would create a new system job for this SLA.

6. Finally, you think you did everything, but you still cannot see your date time field is filled by the SLA due date based on the settings and also there is no System Job created?

Well, it is time to check, are you accidentally change the System Settings?

By Default, it will always Enable.



*For CRM 2013 version, please check in the System Settings –> General Tab and you will find the settings in the bottom

7. And again… You still cannot find it?

Well… This is what I experienced before..

Please go check your Plugin Registration Tool and expand the CRM Internal Object Model Plugin Assembly




Are you accidentally again disable the Steps?
Please Enable it…



8. You have done everything but still can’t work?

I would suggest to check your SLA Item conditions for ‘Applicable When’.

I found some conditions did not work such as i tried using multiple lines of text with operator contains, I am not sure it is a bug or what, but in CRM 2013 SP1 I tried this condition did not work, and also I did try using the related entity field as the trigger point, such as using a field from Customer (lookup field in the Case)  as the condition, it did not work, unless I add one more condition from the Case field itself. It does make sense because CRM use workflow on case entity, if you change anything in the Customer entity field, oob workflow won’t change anything in the Case entity, right..

Because Case is another entity and it is a child of the Customer (Account/Contact) entity.

So, I found that changing my condition with another flag make it works perfectly.

I share this because I was frustrated finding out what happened to my Out of the box SLA.

For another info how the system calculate the SLA by Business Hours, you can refer to this blog:
http://missdynamicscrm.blogspot.sg/2015/02/sla-fields-first-response-by-and-resolve-by-values-crm-2013-2015.html

Hope this helps!

Thanks.

Saturday 16 May 2015

There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:query. The InnerException message was 'Error in line x position y. Element 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:anyType' contains data from a type that maps to the name 'System.Collections.Generic:List`1'

When you do the ConditionOperator.In in your Query during perfoming RetrieveMultiple, you might encounter this error.

“The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:query. The InnerException message was 'Error in line x position y. Element 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:anyType' contains data from a type that maps to the name 'System.Collections.Generic:List`1'. The deserializer has no knowledge of any type that maps to this name. Consider changing the implementation of the ResolveName method on your DataContractResolver to return a non-null value for name 'List`1' and namespace 'System.Collections.Generic'.'.  Please see InnerException for more details.”

Well, here is the way how I solve this.

Root Cause

Actually, the Root Cause is because I was passing the List<object> rather than an Array, which resulted to the error.

Solution

I just change my code

From:

List<Guid> guidMyIds = new List<Guid>();
//I call the function to return list of Guid's
guidMyIds = GetGuidList();
qx.Criteria.AddCondition("guid", ConditionOperator.In, guidMyIds);

Then I change to
List<Guid> guidMyIds = new List<Guid>();
//I call the function to return list of Guid's
guidMyIds = GetGuidList();
qx.Criteria.AddCondition("guid", ConditionOperator.In, guidMyIds.ToArray());

I just change the list to array and now it works.

guidMyIds.ToArray()

Hope this helps!

Thanks!

Sunday 10 May 2015

Tips: CRM C# Create Validated Parent and Child Records at Once as one Big Compound using ‘Related Entities’

Business Requirement

Often, we have requirement to create records which are having Parent and Child Relationship.

For example, Transaction and Transaction Detail (custom entities), Quote and Quote Product, Account/Contact and Activities (Task, Letter, Phone Call, etc).

Commonly, we will create 2 requests, one for Parent (create) and another one to create Child record.

Have you imagined that during the creation of the Parent and Child, the Parent is successfully created, but the Child is not. A good action on this is doing the rollback, otherwise, you will be confused, where is the detail of this, imagine, A Quote without Product, a Header without Detail, in fact Detail is very important in your Business Requirement.

Often we are faced with situation that details are even more important than the header, because header is just summary or just a ‘virtual place’, contrived to group it and store the relationship, while per detail line item is the most important data.

To know the purpose of my post, let’s start this scenario.

Scenario

I need to create an Account with 5 Letters.

My Point is, I receive 5 letters from the same company (Dynamics Bank), but in my database, there is no that Account data, so based the received 5 letters, I want to create the Account.

As we know, Account is the Parent of the Activities and I would like to create the Dynamics Bank before linked it to the letters.

So, I use this code

Code #1

I use the common code..
(I use Late Bound, you can change to Early Bound as well)

private void CreateAccountandLetters(IOrganizationService _service)
{
    try
    {   Guid guidCreatedAccount = Guid.Empty;
        //Account
        Entity accountToBeCreated = new Entity("account");
        accountToBeCreated["name"] = "Dynamics Bank";
        guidCreatedAccount = _service.Create(accountToBeCreated);

        //Define Letters (5 letters)
        /Make sure that will link to accountId
        if(guidCreatedAccount != Guid.Empty)
        for (int i = 1; i <= 5; i++)
        {
            Entity eLetter = new Entity("letter");
            eLetter["subject"] = string.Format("Company Letter {0}", i.ToString());
            //make it linked to the newly created Account..
            eLetter["regardingobjectid"] = new EntityReference("account", guidCreatedAccount);
            //create the Letter with Account related
            _service.Create(eLetter);
        }                            
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

My method here is I create the parent, then inside the for looping, I create child one by one.

Everything is okay, since I can see the Account and 5 Letters.

image

Because that is very simple one, now let’s add one more attribute to the Letter, duration for example.

Code #2

I will add new attribute and I purposely put a mistake to make sure that one of the child will not be created.

private void CreateAccountandLetters(IOrganizationService _service)
{
    try
    {
        Guid guidCreatedAccount = Guid.Empty;

        //Account
        Entity accountToBeCreated = new Entity("account");
        accountToBeCreated["name"] = "Dynamics Bank";
        guidCreatedAccount = _service.Create(accountToBeCreated);

        //Define Letters (5 letters)
        //Make sure that will link to accountId
        if(guidCreatedAccount != Guid.Empty)
        for (int i = 1; i <= 5; i++)
        {
            Entity eLetter = new Entity("letter");
            eLetter["subject"] = string.Format("Company Letter {0}", i.ToString());
            //make it linked to the newly created Account..
            eLetter["regardingobjectid"] = new EntityReference("account", guidCreatedAccount);                

            //put a mistake here
            if (i == 5)
            {
                eLetter["scheduledstart"] = "today";
                //it should accepts datetime only, since it is a datetime field
            }

            //create the Letter with Account related
            _service.Create(eLetter);
        }                          
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

Please notice the eLetter["scheduledstart"] = "today";

As we can see, I receive an expected error.

image

Because the attribute value is expecting Datetime type, not a string.

Now, let’s we see the result..

image

Well, you can see that 1 Account: Dynamics Bank is still created and other 4 letter records are also created.

In fact, this is not what we want! This is not a perfect solution.

We want to create 1 Account with 5 Letters with 100% fully successfully or not at all!

Since we use the method by creating the record, 1 by one, we will have this problem.

*If you notice we have called at least 6 Create request for this, and if one the children is failed, we can still see the others.

Now, what is the solution?

After though reading, I found this article..

https://msdn.microsoft.com/en-us/library/gg309282.aspx

It was using the CompoundRequest method, which was deprecated, replaced by standard create or update with related entities property.

Code #Related Entities

You can do a rollback by creating additional custom code to delete the Account + 4 Letter records in the end.

But, actually, we have better solution, that is using the Compound Request method and utilizing the Relationship object.

Here is the code:

private void CreateRecordsWithRelatedEntities(IOrganizationService _service)
{
    try
    {
        //Define the account for which we will add letters                
        //Account
        Entity accountToBeCreated = new Entity("account");
        accountToBeCreated["name"] = "Dynamics Bank";

        //This acts as a container for each letter we create. Note that we haven't
        //define the relationship between the letter and account yet.
        EntityCollection relatedLettersToBeCreated = new EntityCollection();
        for (int i = 1; i <= 5; i++)
        {
            Entity eLetter = new Entity("letter");
            eLetter["subject"] = string.Format("Company Letter {0}", i.ToString());

            //put a mistake here
            if (i == 5)
            {
                eLetter["scheduledstart"] = "today";
                //it should accepts datetime only, since it is a datetime field
            }

            //bind to the EntityCollection of the related records
            relatedLettersToBeCreated.Entities.Add(eLetter);
        }

        //Creates the reference between which relationship between Letter and
        //Account we would like to use.
        Relationship letterRelationship = new Relationship("Account_Letters");

        //Adds the letters to the account under the specified relationship
        accountToBeCreated.RelatedEntities.Add(letterRelationship, relatedLettersToBeCreated);

        //Passes the Account (which contains the letters)
        _accountId = _service.Create(accountToBeCreated);
        //and guess, you only need 1 request for all records!!
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

And as you can see, we got the expected error (same error, actually)

image

And here is the result

image

*There is no Account created, nor any Letter records as well..

Because, in fact, they are 1 big compound, once one is failed, it will totally make others failed as well.

Now, let’s make no mistake and let those records created successfully, i just remove the lines making it failed.

image


Result:

image

Now, those 6 records are 100% created.

This method is very useful if you are required to focus to the big compound and 100% completeness is your absolute goal.

Imagine that you will have a trouble and headached if you need to create multiple records and make sure they are created in the same time, while in fact, one mistake makes one record not created..

Then, you need to do a rollback!! How many new lines of code you need to do checking for rollback? While you can make them as the big one rock that is not separable.

Here is the complete code:

private void CreateRecordsWithRelatedEntities(IOrganizationService _service)
{
    try
    {
        //Define the account for which we will add letters                
        //Account
        Entity accountToBeCreated = new Entity("account");
        accountToBeCreated["name"] = "Dynamics Bank";

        //This acts as a container for each letter we create. Note that we haven't
        //define the relationship between the letter and account yet.
        EntityCollection relatedLettersToBeCreated = new EntityCollection();
        for (int i = 1; i <= 5; i++)
        {
            Entity eLetter = new Entity("letter");
            eLetter["subject"] = string.Format("Company Letter {0}", i.ToString());

            //bind to the EntityCollection of the related records
            relatedLettersToBeCreated.Entities.Add(eLetter);
        }

        //Creates the reference between which relationship between Letter and
        //Account we would like to use.
        Relationship letterRelationship = new Relationship("Account_Letters");

        //Adds the letters to the account under the specified relationship
        accountToBeCreated.RelatedEntities.Add(letterRelationship, relatedLettersToBeCreated);

        //Passes the Account (which contains the letters)
        _accountId = _service.Create(accountToBeCreated);
        //and guess, you only need 1 request for all records!!
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

The most important part to identify a compound is this:

//Adds the letters to the account under the specified relationship
 accountToBeCreated.RelatedEntities.Add(letterRelationship, relatedLettersToBeCreated);

While you need to defined the Relationship Name and the Entity Collection of the related entities.

With this method, you can validate the united records as one big compound, either 100% created or 0% created..

For me, I have requirement to make sure that between Header and Details are always in sync, so yes, I need the 100% not a partial compound.

So, I found this method is very useful and this method might not be popularized explicitly. Thus, I want to introduce and share it out, to make this method more useful.

Hope this helps you!

Thanks.

CRM 2015 Update 1: Themes and UI Mapping Dictionary

Here is the mapping between actual UI and the Theme Attributes value in new CRM 2015 Update 1 version

Navigation Bar

image

Form Navigation

image

Entity View navigation

image
image

Form

#1 System User Form (as Example)
image

image
#2 Case With Business Process Flow (as Example)
image

View

#1 Main Entity View
image

image

#2 Sub-Grid View
image
#3 Associated View
image

Legend

Logo

image

Logo Tooltip: Miss Dynamics CRM

Color
No Attribute Name Color
1 Navigation Bar Color
2 Navigation bar Shelf Color
3 Header Color
4 Global Link Color
5 Selected Link Effect
6 Hover Link Effect
7 Process Control Color
8 Default Entity Color
9 Default Custom Entity Color
10 Control Shade
11 Control Border

If you see different color for entities in the sitemap (such as Lead and Opportunity, and also Product), so it means they have been modified individually through Customization.

http://missdynamicscrm.blogspot.sg/2015/05/crm-2015-update-1-sitemap-entity-color.html

For the detail info, I have posted to this post..

And hope this helps!
Thanks.

CRM 2015 Update 1: Exploring and Understanding Themes Deeper

Theme?


Theme is new feature and also new entity introduce in CRM 2015 Update 1.This is coming as the new trend and becoming fewer in term of the new improvement in UI design for most CRM User, who has been expecting this for long time.
Now, in my post, let’s we discover more about Theme, especially its attribute.

Overview

This is the list of Theme Attributes:
Schema Name Type Value of default theme Description
ControlBorder String #CCCCCC The color that controls will use for borders.
ControlShade String #F3F1F1 The color for controls to use to indicate when you hover over items.
DefaultCustomEntityColor String #006551 The default custom entity color if no color is assigned.
DefaultEntityColor String #8B98AB The default color for system entities if no color is assigned.
GlobalLinkColor String #1160B7 The color for links, such as email addresses or lookups.
HeaderColor String #1160B7 The color for header text, such as form tab labels.
HoverLinkEffect String #D7EBF9 The color that commands or lists will use when you hover over the items.
LogoId String null The name of a web resource to use as a logo. Recommended dimensions are a height of 50 pixels and a maximum width of 400 pixels.
LogoToolTip String Microsoft Dynamics CRM The text that will be used as the tooltip and alt text for the logo.
Name String CRM Default Theme The name of the Theme entity.
NavBarBackgroundColor String #002050 The primary navigation bar color.
NavBarShelfColor String #DFE2E8 The secondary navigation bar color.
ProcessControlColor String #0755BE The primary color for process controls.
SelectedLinkEffect String #B1D6F0 The color that commands or lists will use to indicate selected items.

Source: https://msdn.microsoft.com/en-us/library/dn932133.aspx

Effect of Attributes

We know there are lot of attributes inside this Theme entity, which if we can’t understand their effects, will make our CRM not better, in fact is becoming more and more ugly + weird!
Now, let’s we begin our journey together.

image

Theme Name

Theme Name has only one field inside this section.
Theme Name
Okay, this is just a Name.
Remember, every entity in this world needs a name, that happening also in our Dynamics world, every entity in CRM needs a name! This is for instance identification only, can’t imagine if you create record then you do not name it, you will be confused.

image

Navigation Bar

Navigation Bar has 5 attributes inside this section
Logo
Logo is the one that will replace this CRM fav icon.. In the left side Top navigation.

image
To use your image as Logo, you need to upload it as Web Resource.
image

And here is the effect after you change it.

image

I recommend you to upload an image that height is not more than 48px and if possible, use the  .PNG with transparent BG, otherwise you will get an awkward design or you need to adjust the Navigation BG-Color.

If I use the transparent, I can choose my own Navigation Bar Color easily

image
Logo Tooltip
This is Tooltip for your logo that only appear if you Hover it.
image

Result:

image
Navigation Bar Color
This is the Main navigation color, it was defaulted to CRM Signature Blue Color

image

Now, let’s I change it to Green Color

image
Navigation bar Shelf Color
This setting is for the second layer of top navigation.

image

To make it flashy, I change to pink Color and you will see its difference.

Previously was:

image

Now is..

image

*All customized:

image
Header Color
Header Color is: “The color for header text, such as form tab labels.”

I change to:

image

This will determine the Navigation Text:










This is related to the Form also actually.


image

I change to other Color

image

Once you know its effect, you will be more careful to put your colorizing setting.

UI Elements

Global Link Color
If you notice, current version of CRM will have the link color, like you often defined in your CSS Styling

Previous version

image

CRM 2015 Update 1

image

For the lookup and email, now we can define our own color.

I change the color

image

Result:

image

And also for the Form level

image

In fact, it will affect any hyperlink.
Selected Link Effect
When you select an item or multiple items, you can see the color appearing, like in previous version:

image

Now, you can change its color

image

Result after changing it.

image

*Considering this I think it is not so that less important setting…hehe
Hover Link Effect
Related to previous, but this time, this color will appear only if we hover it on, not when we select it.

image

Now, i change to other color:

image

Result:
image

Not only to record, it also affect the ribbon!!

image
Process Control Color
Short word, it is related to the Business Process Flow

image

Now, I change the color to:

image

Result:

image

Default Entity Color
Remembering in forum that I have been active member, many people asking this feature and I always say, not, it is not possible. Now, I can say, yes, it is!

And what is the feature?

We can change the Entity Color in your sitemap!

Yeah..

And this is just a default one..

image

image

You must see the pink color box

image

When I say just ‘default one’, so yes, can we customize it?

Well, each individual entity, you can also defined, for those who are not defined in the Customization will get the default value, same as Custom Entity, you can change individually the color, please refer to this post.

http://missdynamicscrm.blogspot.sg/2015/05/crm-2015-update-1-sitemap-entity-color.html

image

Result:

image
Default Custom Entity Color
This is same as the previous one, but it is mainly for defaulted custom entity color!

image
Control Shade
This is related your activity when you try to hover a control (not a ribbon, because ribbon is controlled by another setting)

image

Result:

image
Control Border
image

Result:

image

After we know their effects, we might need to be careful to give them color because it can affect your CRM User Interface.

Hope this helps!
Thanks.