Posts

Showing posts from August, 2011

CRM 2011 Convert Activity to Case - Populate Case Details

When converting an activity (such as Phone Call) to case, we can only specify the Customer and the Subject on the popup dialog. What if we want to auto-populate the case details with the information from the activity? At first I thought we can write a plugin that triggers on the post-create of a case. However this is not possible since CRM creates the Case before it sets the Regarding field on the Activity. The workaround for this is to create the post-update plugin on the Activity itself. This way when the Regarding field is assigned by CRM, it will look for the Case and update its details. Be careful though because this might not work when converting Activity to Case from Outlook. I read somewhere that when converting Email to Outlook, the Regarding field is set to the Parent Customer of the Case rather than the Case itself. Hope this helps, Andreas

CRM 2011 Custom Filtered Lookup

Image
Sometimes the filtered lookup functionality provided by CRM 2011 doesn't fit your requirement. However Microsoft provides a function for us to add our own custom view for the lookup field. Example: In a 'Case' form we have customer field. I use this field only for 'Contacts', and I have created a relationship to the 'Account' so that we can see both on the form. I want the Accounts to only show Contacts that have 'Connections To' and vice versa (Only show Contacts that have 'Connections From' if I specified the Account first). If nothing is specified then I want both to show just Active Contacts/Accounts. The script: Then you can use it like this: However there is still a major limitation of FetchXML that you cannot use UNION clause (or something similar). So If you want to show the primarycontact/parentcustomer along with the connections, you're out of luck as you can only do one of them. Hope this helps, Andreas

CRM 2011 Javascript Retrieve Record using jQuery REST Endpoints.

Using jQuery and REST Endpoints is one of the easiest way to get record details in CRM 2011. To do this you just need to include: 1. jquery-1.6.2.min.js (or just get the latest version) 2. json2.js The SDK provides some functions for retrieving records: Use retrieveRecord if you know the ID of the record. Otherwise, use retrieveMultiple if you want to get the record(s) based on some filters as it will return an array of result objects. Example: In a custom entity form, I have an Account lookup field and an Account Number field. I want to auto-populate one of the field based on the other field and vice versa. Therefore: Hope this helps, Andreas

CRM 2011 Auto-populate Name from Fields or Attributes

Are you tired of thinking about what to put into the name field when creating records and want a way to populate that name automatically? I have created a service extension method to make my life easier. The goal of this is to autopopulate name field using the format like [field1] - [field2] - [field3] through pre-plugin: To use this you just need to construct the column set and pass in the entity from the plugin context: We also need a javascript to disable this name field when the form load: Hope this helps, Andreas

CRM 2011 Refresh Form after Subgrid Changes or Refresh

I found on some articles that to be able to do this you need to attach an OnRefresh event to the element that then calls the function to load the parent window again: When I deployed to CRM 2011 Rollup 3, I found some issues that throw error like null object (document not ready) and in some IE versions the form keeps refreshing for eternity... After spending some time investigating this annoying issue, I found out that we have to wait for the subgrid to finish loading its contents for this to work properly. The final javascript is as follows: Hope this helps, Andreas

CRM Report Pre-Filtering with Multiple Datasets

As you know there are two ways of doing pre-filtering with CRM Reports (SQL and not FetchXML). The first one is using the CRMAF_ prefix alias like this: I soon found limitation using this method. You can't use the same CRMAF_Filtered multiple times because it only filters on the first instance. Therefore if you have multiple datasets or UNION query that are using that filter more than once, it will not work. To avoid this issue, we can use the Explicit pre-filtering - the second method that CRM provides. Let's say that you want to have a report that display single Account details and the associated related records information. However rather than building complex single query you want to break it down into multiple datasets. The Steps: Create a parameter called @CRM_FilteredAccount. You can set the default value to just: Build your datasets using this parameter. Use the SQL Dynamic Query so that CRM will replace the parameter with the Advanced Find instance that...

CRM 2011 Embed Report in IFrame and Pass Parameters from the Form

Image
In CRM you can insert SubGrid and Chart. However this functionality is limited in a way that it can only grab the related entities that have direct relationship to that entity. If we want to get the other related entities from the related entity, it's not possible using the OOTB Subgrid and Chart. In my case I want to display a chart in an Engagement Plan entity. This Engagement Plan is associated with an Account (N:1). The Account has 1:N relationships with Production History and Contract History entities that have information about commodity and tonnes produced. I want that chart to be shown on the Engagement Plan form. The parameters for this chart will be the Account Id and the Season Id located on the form. The Steps: Create a custom SSRS Report to display this chart, taking @CRM_AccountId and @CRM_SeasonId as parameters. Insert an IFRAME on the form and give dummy Url. Also uncheck 'Restrict Cross Site Scripting' to allow cross scripting between servers. ...

CRM 2011 Report Error - rsProcessingAborted

I encountered this error in my project when trying to run CRM reports within CRM (including the default reports). In the reportservice logs it says: Cannot create a connection to data source 'CRM'. ---> Microsoft.Crm.Reporting.DataExtensionShim.Common.ReportExecutionException: Immediate caller Domain\SqlService has insufficient privilege to run report as user S-1-5-21-1162093662-620106126-315576832-39399. The CRM is installed on the application server and the SSRS is installed on different server. After futher investigation it turns out that it's caused by double hopping issue regarding the authentication and we just need to set the correct SPN on the machines. setspn -a http/your-crm-server-name domain\crm-user  setspn -a http/your-crm-server-name(FQDN) domain\crm-user Other things to check to make sure your reports work: 1. Make sure your SRS connector has the same RollUp version as the CRM Server RollUp 2. In Reporting Service Configuration Manager, unche...

CRM 2011 Plugin Template

Here is the template to get you started on plugin development in CRM 2011: To get the service context of your organisation : Important Notes: PRE PLUGINS You don't need to call SaveChanges because the entity can be updated before it is saved into database. For pre-update, entity will only have attributes that are changed. To get the other attributes that don't change, you can query those attributes using the service context. POST PLUGINS You need to call SaveChanges because the entity has been saved into database. Entity will have all updated attributes when retrieved using service context. When doing the post update of an entity that update the same entity attributes, loop will occur. To avoid this you can use context.Depth to check the loop count. OTHERS For delete message, the context.InputParameters["Target"] is an EntityReference instead of Entity. You can check the context message using context.MessageName Hope this helps, Andreas