Tag Archives: CRM 2011

How – To Series 16: UR 12 – Downside of Auto Save feature

Update: This issue is fixed now with MS CRM 2013 Org Level Setting. Following is the update:
https://connect.microsoft.com/dynamicssuggestions/feedback/details/777281/ur-12-auto-save-feature-causing-workflows-plugins-to-be-triggered-multiple-timesHi all,
UR 12 has introduced a nice feature called “Auto Save” which will save the CRM Records(only Process Driven UIs) in the background automatically when it get updated by the user in UI.

When a field value changed by user, in the bottom right corner a label as “Unsaved Changes” gets displayed:

After few seconds(15-20 sec), forms gets saved automatically:

From usability point of view, it’s a very nice feature… then what’s going wrong??

When I came to know about this feature, few things came to my mind:

Scenario1: Lets say I have registered a workflow or a plugin on “onChange” of a field called “fax” in “account” entity. User has entered some value(1234) in the “fax” field and went on to fill other fields. After few seconds(lets say 20 sec) form gets saved automatically in the background. Incase if user feels he entered some wrong value in “fax” field so he/she modified the field again.

Prior to UR12 or with Classic Forms: User saves the form manually. Even though user modifies the same field twice, field value gets saved to the database once(in one transaction). And the workflow which is registerd will fire once and completes it’s tasks.

with UR12 Process Driven Froms: As user modifies the same field twice(one before the auto save and one after the background save), field value gets saved to the database twice(in two transactions). And the workflow which is registerd will fire twice…..

Scenario2: Lets say I have registered a workflow or a plugin on “onChange” of fields called “fax” and “email” in “account” entity. User has entered some value(1234) in the “fax” field. After few seconds(lets say 20 sec) form gets saved automatically in the background. Then user modifies the “email” field. After few seconds form gets saved in the background

Prior to UR12 or with Classic Forms: User saves the form manually. workflow will be triggered only once.

with UR12 Process Driven Froms: As user modifies two fields (one before the auto save and one after the background save), two field values gets saved to the database in two different transactions. And the workflow which is registerd will fire twice…..

To verfiy that, I have registered a workflow on “fax” and “email” field. Added a step to attach notes with fax and email field vlaues:

Result after Scenario 1:

Workflow instances:

Created Notes:

Created Notes when fax got updated to 1234

Created Notes when fax got updated to 1234567

In the same manner, for the second scenario too workflow got triggered twice…

Is it the expected behavior??? or Is it a design glitch??? or something am I missing??? So, if we gonna use Process Driven forms then what should be the considerations for extending the entity behavior??

Fingers Crossed….!!! 🙂

Share me your thoughts…!!!

How – To Series 15: UR 12 – How to enable Process Driven Forms

Hi all,
The most feature rich release(Polaris) post CRM 2011 has already been out and excited to see the same applied on my CRM online instance. Following is the snapshot of CRM 2011 in Chrome Browser.CRM Online(Polaris) Landing Page:

Account Home Page Grid:

Account Form:

Few observations:

1. As expected, “Areas” in Left Navigation Pane doesn’t have icons.
2. “Resource Center” still exists as it should not(we will come to know when it will be removed)
3. In “Account” grid, “account” icon column has been removed.
4. Coming to Ribbon, disabled ribbons are greyed but still retaining their icon colours.
5. Tab text colour changed to light blue and size got decreased.
6. No divider line between header and body
7. New icons(refresh, arrow buttons etc..)
8. Significant control highlighting with border when it get focused
9. And the notable difference is in “Notes” Section:

Now, we can type notes text and upload an attachment at one go whereas earlier it used to be one after the other.

Overall at first glance you can find certain CSS changes. In order to find exact CSS changes I downloaded the SDK v5.0.13 for polaris & UR12 . However, the visual style guide doesn’t include the latest CSS changes. Is it a miss in the package??

Now, lets come to the main course…where are the Process driven UI for Account, Contact and Opportunity entities? As we heard it earlier that there will be a new form for each entity(Account, Contact and Opportunity)which will have same name as their entity schema name. However, in the above account form, you don’t see it having an option to select another form. As most of you might have already know that we need to explicitly enable this feature so as customer will have the flexibility to choose when they require this. Remember once this feature is enabled we cannot revert it.

To enable, navigate to “Settings->Administration->Product Updates and click on “Update” button

It will take few minutes to install the updates. Once it gets installed, you will see the following content:

Installation process actually involves in creating the new UI forms, a new entity called “Process Configuration”, appropriate assignment of privileges and all the required components for them.  However, the new UI forms won’t contain all the customization whichever we have done prior to UR12. So, we need to migrate them manually(First point in the above screenshot talks about that). As I am having a new CRM instance which doesn’t have any customizations, I am good to go and use the new UI forms as is. Again, you are not yet done. Click on the second link(Enable the new forms) to enable the new UI feature.

Refresh your page and you can see that “Resource Center” Area has been disappered.

Account Form(Process driven):

Contact Form(Process driven):

Opportunity Form(Process driven):

Getting a taste of Metro Style design app in CRM…???

There are lot more stuff of UR 12 to try out… Happy CRMing..!!! 🙂

Hope it helps..!!! 🙂

 

Post Sync Plugins not allowed for certain System entities?

Hi,
I was getting some errors when trying to associate some records on creation of “User” and “Team” entities. I have registered “Post – Sync” step for those plugins.Getting following error for “Post” “Sync” plugin on “User” creation:
Error: usersettings with Id Does not Exist.

 

Getting following error for “Post” “Sync” plugin on “Team” creation:
Error: Generic SQL Error.

Changing them from “Post – Sync” to “Post – ASync” resolved the issue. It looks like SQL Locks might be causing the issue. There may be few more System entities for which the same is applicable. There is no documentation available specifying for which System entities creation “Post – Sync” plugins are not allowed. So, next time if you get any of the above errors for any of the other entities then try to change it to “ASync” and see whether it resolves your issue.

Hope it helps..!!! 🙂

Hidden Security Role in MS CRM….!!!????

Hi,
     Recently I was trying to assign all the available Security Roles in a Business Unit to a particular User using following Code:

     private void AssignSecurityRoles(IOrganizationService service, Guid userId)  
     {  
       QueryExpression query = new QueryExpression  
       {  
         EntityName = "role",  
         ColumnSet = new ColumnSet("name")  
       };  
       EntityCollection roles = service.RetrieveMultiple(query);  
       EntityReferenceCollection entityRefCln = new EntityReferenceCollection();  
       foreach (Entity entity in roles.Entities)  
       {  
         entityRefCln.Add(entity.ToEntityReference());  
       }  
       service.Associate("systemuser", userId, new Relationship("systemuserroles_association"), entityRefCln);  
     }  

To my suprise, I received following error: “The Support User role cannot be assigned to a User”


After debugging the code, I found that there is one role called “Support User” security role present in the list of retrieved security roles. I never seen this role in the CRM UI so quickly went through the CRM UI app and to my surprise it is not available. However, it is present in the SQL Server… !!! Doesn’t it mean it’s a hidden role???? Not aware of the actual purpose of this role. As per SDK documentation, “A user who is a customer support engineer” is the description for the Security Role.

I added an additional conditional to avoid associating “Support User” security role for the time being. Anyone has an idea about the purpose this Security Role????
    

How – To Series 12: Another restriction from Field Leve Security….!!!?

Hi,
We all know that only OOB fields have been restricted from Field Level Security and all the custom fields can have Field Level Security. However, today i tried creating a new field of type “Single Line of Text” of format”EMail” with “Field Level Security” enabled.To my surprise I can see the following error:

And this is the error message in the Log file: “This field is not
securable”

I raised this issue with MSConnect here . Need to findout whether its bug or by design.

How-To Series 10: How To get Selected Record Entity Name from Activities or Queue Item Entity Home Page Grid

Hi All,
           We know that we can use “SelectedEntityTypeName” to get the selected record’s “Entity Name” in a Grid. This is useful for every entity with an exception to couple of entities like “Queue Item” and “Acitivity” HomePage Grids as these will display records belongs to more than one entity. For an instance, “Activities” will display “EMail, Phonecall, Appointment etc..”. 
           So, if you want to retireve the selected record’s entity name then use the following function. The following function requires all the views in the grid to have the entity name as one of the column at the same location. It will retrieve selected record’s Id along with its entity name. Its the same way we used to do in CRM 4.0’s ISV.Config.
function ShowSelectedIdsWithEntityName()
{
var selectedrecords = document.all[‘crmGrid’].InnerGrid.SelectedRecords;
for (var i=0; i < selectedrecords.length; i++)
{
//This will return the selected record guid
alert(“Selected Record Id: “+selectedrecords [i][0]);
// This will return the 5th column data. OOB, in “Queue Item” entity “Type(Entity Name)” is the 5th column for all views.
alert(“Selected Entity Name: “+selectedrecords [i][3].cells[4].innerText);
}
}

Following is for “Queue Item” entity.
 

Hope it helps….

Cheers
Vikranth P.

How-To Series 9: Dynamic Ribbon Controls using CommandProperty – Infinite loop issue

There is nice article from MS Blog on creating dynamic ribbons in CRM 2011 http://blogs.msdn.com/b/crm/archive/2011/03/30/create-dynamic-ribbon-controls.aspx. I have followed the same approach to create a split button. However, here in my case we want to have the Menu XML dynamically generated based on some entity data. However, there was a problem when we tried to do that using ODATA query. There was nothing wrong in the code. ODATA query was able to retrieve the data and pass the result set to the call back method to populate ribbon split button. However, once the population is done in the code, control is moving back to starting point in the code(function DynamicMenu(CommandProperties)). It’s going into infinite loop.
function DynamicMenu(CommandProperties)
{
getData(CommandProperties, SuccessCallBack, ErrorCallBack);
}
function getData(CommandProperties, SuccessCallBack, ErrorCallBack)
{
//ODATA Stuff
success: function (data, textStatus, XmlHttpRequest)
        {
              // Success Call Back
       SuccessCallBack(CommandProperties,data);
        },
//ODATA Stuff
}
function SuccessCallBack(CommandProperties,data)
{
// Split Button population stuff
}
After bit(I can say a lot of) of struggle I felt it might be due to Asynchronous AJAX call in the script. To verify that I have commented ODATA call and kept “SetTimeOut(method(),4000)” in my code and did populate split button using static MenuXML. It’s again going to infinite loop. This time I have commented  “SetTimeOut” method too. Now, it’s working perfectly.
So, i thought of replacing ODATA Async Call with SOAP Synchronous call. This time it worked like a charm.….!!!!!! J
Hope it helps…!!!!
Cheers
Vikranth Pandiri

How To – Series 8: Cross Domain Issue while working with CRM 2011 Web Services in JScript

Back to blogging after long time. Recently I faced a “Cross Domain” issue while working with Jscript ODATA query. Below is the code which I have used:
    var ODATA_ENDPOINT = “/XRMServices/2011/OrganizationData.svc”;
    var context = GetGlobalContext();
    var serverUrl = context.getServerUrl();
   
    //Asynchronous AJAX function to Retrieve a CRM record using OData
    $.ajax({
        type: “GET”,
        contentType: “application/json; charset=utf-8”,
        datatype: “json”,
        url: serverUrl + ODATA_ENDPOINT + “/AccountSet?$filter=Address1_City eq ‘Redmond'”,
        beforeSend: function (XMLHttpRequest)
        {
            XMLHttpRequest.setRequestHeader(“Accept”, “application/json”);
        },
        success: function (data, textStatus, XmlHttpRequest)
        {
              // Success Call Back
        },
        error: function (XmlHttpRequest, textStatus, errorThrown)
        {
              // Error Call Back
        }
    });
The REST End point “url “ which I am passing in the above code is: http://<server>/<orgname>/XRMServices/2011/OrganizationData.svc/AccountSet?$filter=Address1_City eq ‘Redmond’.This code only works when we open CRM records using CRM “Server” name. It fails in other cases like when we open it using IP Address or localhost. The primary reason for this is due to “Cross Domain Policy”. The blocker is the REST End point which we are using. 
So, I thought of replacing server name with IP Address as follows.
I ran it in the browser…. It worked…!!!! J
So, I got a simple solution. 
Use the following instead of getting “ServerUrl” from the context object.
    var serverUrl = window.location.protocol + “//” + window.location.host + “/” + context.getOrgUniqueName();
Here we just need to use the window.location property to get the current window protocol and host and build the REST Endpoint.
Hope it helps…!!!! Please let me know if we have any other alternative solution. 
Cheers
Vikranth Pandiri.

How To – Series 7: How To override(Enable, Disable, Show, Hide, Custom Logic) Out of the Box HomePageGrid ribbon elements – CRM 2011

Hope my earlier posts on Ribbon elements helps you. In this post we will see how to Enable/Disable Out of the Box ribbon elements in Dynamics CRM 2011. After going through the SDK, it seems there is no direct solution to override existing <CommandDefinition>. However, the documention says using <CustomAction> we can Add or Replace items in the ribbon. It gives me an idea to replace existing OOB(Out of the Box) ribbon item with Custom ribbon item and define our own <CommandDefinition> for that. At the same time we can also go with the OOB <CommandDefinition>. Lets see how we can do that stuff.

Lets consider “Edit” ribbon item on the “Account” entity “HomePageGrid”. I want to disable this “Edit” button when user selects more than one record in the sub grid(i.e I don’t want “Bulk Edit” feature for Account records). The same can be achieved with security roles. However, for the sake of simplicity and to focus more on how we can override <EnableRules>, <DisplayRules> and <Actions> for an OOB item I have considered this scenario.

 

Step 1:

 

Open “accounribbon.xml” file from the “sdksamplecodecsclientribbonexportribbonxmlexportedribbonxml” location in the CRM 2011 SDK.

 

Below is the definition for “Edit” button

 

<Button Id=”Mscrm.HomepageGrid.account.Edit” ToolTipTitle=”$Resources:Ribbon.HomepageGrid.MainTab.Management.Edit” ToolTipDescription=”$Resources(EntityDisplayName):Ribbon.Tooltip.Edit” Command=”Mscrm.EditSelectedRecord” Sequence=”20″ LabelText=”$Resources:Ribbon.HomepageGrid.MainTab.Management.Edit” Alt=”$Resources:Ribbon.HomepageGrid.MainTab.Management.Edit” Image16by16=”/_imgs/ribbon/Edit_16.png” Image32by32=”/_imgs/ribbon/edit32.png” TemplateAlias=”o1″ />

 

 

Below is the <CommandDefinition> for “Edit” button.

 

 

<CommandDefinition Id=”Mscrm.EditSelectedRecord”>

 

        <EnableRules>

 

          <EnableRule Id=”Mscrm.CheckBulkEditSupportForEntity” />

 

          <EnableRule Id=”Mscrm.VisualizationPaneNotMaximized” />

 

        </EnableRules>

 

        <DisplayRules>

 

          <DisplayRule Id=”Mscrm.BulkEditPrivilege” />

 

          <DisplayRule Id=”Mscrm.WriteSelectedEntityPermission” />

 

        </DisplayRules>

 

        <Actions>

 

          <JavaScriptFunction FunctionName=”Mscrm.GridRibbonActions.bulkEdit” Library=”/_static/_common/scripts/RibbonActions.js”>

 

            <CrmParameter Value=”SelectedControl” />

 

            <CrmParameter Value=”SelectedControlSelectedItemReferences” />

 

            <CrmParameter Value=”SelectedEntityTypeCode” />

 

          </JavaScriptFunction>

 

        </Actions>

 

      </CommandDefinition>

 

 

Copy both of the definitions and we gonna use them in the next steps.

 

Step 2:

 

Add “Account” entity to a solution. Export it. Open “Customizations.xml” file.

 

Go to <EnableRules> section and add following <EnableRule> which will return “true” when only one item is selected in the sub grid.

 

 

   <EnableRule Id=”Sample.account.grid.OnSelection.EnableRule”>

 

              <SelectionCountRule AppliesTo=”SelectedEntity” Maximum=”1″ Minimum=”1″/>

 

            </EnableRule>

 

 

Step 3:

 

 

Go to <CommandDefinitions> section and add copied <CommandDefintion> form the Step1. Rename “Id” value to “Sample.account.grid.DisableExisting.Command”

 

<CommandDefinition Id=”Mscrm.EditSelectedRecord”>

 

        <EnableRules>

 

          <EnableRule Id=”Mscrm.CheckBulkEditSupportForEntity” />

 

          <EnableRule Id=”Mscrm.VisualizationPaneNotMaximized” />

 

        </EnableRules>

 

        <DisplayRules>

 

          <DisplayRule Id=”Mscrm.BulkEditPrivilege” />

 

          <DisplayRule Id=”Mscrm.WriteSelectedEntityPermission” />

 

        </DisplayRules>

 

        <Actions>

 

          <JavaScriptFunction FunctionName=”Mscrm.GridRibbonActions.bulkEdit” Library=”/_static/_common/scripts/RibbonActions.js”>

 

            <CrmParameter Value=”SelectedControl” />

 

            <CrmParameter Value=”SelectedControlSelectedItemReferences” />

 

            <CrmParameter Value=”SelectedEntityTypeCode” />

 

          </JavaScriptFunction>

 

        </Actions>

 

      </CommandDefinition>

 

 

Add    <EnableRule Id=”Sample.account.grid.OnSelection.EnableRule”/> to the <EnableRules> section.

 

 

<CommandDefinition Id=”Mscrm.EditSelectedRecord”>

 

        <EnableRules>

 

          <EnableRule Id=”Mscrm.CheckBulkEditSupportForEntity” />

 

          <EnableRule Id=”Mscrm.VisualizationPaneNotMaximized” />

 

          <EnableRule Id=”Sample.account.grid.OnSelection.EnableRule”/>

 

        </EnableRules>

 

        <DisplayRules>

 

          <DisplayRule Id=”Mscrm.BulkEditPrivilege” />

 

          <DisplayRule Id=”Mscrm.WriteSelectedEntityPermission” />

 

        </DisplayRules>

 

        <Actions>

 

          <JavaScriptFunction FunctionName=”Mscrm.GridRibbonActions.bulkEdit” Library=”/_static/_common/scripts/RibbonActions.js”>

 

            <CrmParameter Value=”SelectedControl” />

 

            <CrmParameter Value=”SelectedControlSelectedItemReferences” />

 

            <CrmParameter Value=”SelectedEntityTypeCode” />

 

          </JavaScriptFunction>

 

        </Actions>

 

      </CommandDefinition>

 

 

 

Step 4:

 

 

Add following <CustomAction> to the <CustomActions> section:

 

 

          <CustomAction Id=”Sample.account.grid.DisableExisting.CustomAction” Location=”Mscrm.HomepageGrid.account.Edit” Sequence=”21″>

 

            <CommandUIDefinition>

 

              <Button Id=”Mscrm.HomepageGrid.account.Edit” Command=”Sample.account.grid.DisableExisting.Command” LabelText=”$Resources:Ribbon.HomepageGrid.MainTab.Management.Edit” Alt=”$Resources:Ribbon.HomepageGrid.MainTab.Management.Edit” ToolTipTitle=”$Resources:Ribbon.HomepageGrid.MainTab.Management.Edit” ToolTipDescription=”$Resources(EntityDisplayName):Ribbon.Tooltip.Edit” TemplateAlias=”o1″ Image16by16=”$webresource:new_/icons/TIcon16x16.png” Image32by32=”$webresource:new_/icons/TIcon32x32.png” />

 

            </CommandUIDefinition>

 

          </CustomAction>

 

 

Here we need to carefully observe what we have done to replace existing “Edit” button with our own Custom Button.

 

<CustomAction Id=”Sample.account.grid.DisableExisting.CustomAction” Location=”Mscrm.HomepageGrid.account.Edit” Sequence=”21″>

 

 

Here I have given  unique id for the <CustomAction> and for the “Location” attribute I have placed “Id” of the OOB “Edit” button only. I haven’t kept “._children”. This makes all the difference…

 

 

<Button Id=”Mscrm.HomepageGrid.account.Edit” Command=”Sample.account.grid.DisableExisting.Command” LabelText=”$Resources:Ribbon.HomepageGrid.MainTab.Management.Edit” Alt=”$Resources:Ribbon.HomepageGrid.MainTab.Management.Edit” ToolTipTitle=”$Resources:Ribbon.HomepageGrid.MainTab.Management.Edit” ToolTipDescription=”$Resources(EntityDisplayName):Ribbon.Tooltip.Edit” TemplateAlias=”o1″ Image16by16=”$webresource:new_/icons/TIcon16x16.png” Image32by32=”$webresource:new_/icons/TIcon32x32.png” />

 

 

Here, I have given OOB “Edit” button “Id” as the “Id” for the new item. Do remember that, “Id” value in the <Button> should be same as “Id” value in the <CustomAction>. In other words the new Ribbon Item should have same “Id” as the OOB item.

 

For the “Command” attribute I am planning to use OOB Command that has been defined for the “Edit” item. I am planning to use OOB features and in addition to that I am planning to have my own <EnableRules>, <DisplayRules> and <Actions> rules. Feel free to use your own Command if you require to.

 

For remaining attributes also I wish to go with OOB except for the Images. Here I want to show images from my web resource.

 

Now, Import the solution with these changes to your system. Below is the result:

When no recod is selected:

When One record is selected:
When multiple records are selected
In this way we can override OOB behaviors and visualizations for OOB ribbon elements. If you want to have more complex queries for the <EnableRule> then we can use <CustomRule> to call a JScript function. Please see my earlier post here: http://howto-mscrm.com/2011/04/how-to-series-6-how-to-use-customrule.html on how to use <CustomRule> with “HomePageGrid”.
Hope it helps everyone. 🙂

Cheers…!!!
Vikranth Pandiri.