Posts

CRM 2011 LINQ Left Join Through Entity Reference

Let's say we have a custom lookup field new_accountid on our phonecall activity (don't ask me why I don't just use from/to field :)) and that field is NOT a required field. We want to get the account number using LINQ in our code somehow. This is the way to do it. The trick is that we have to check whether the new_accountid is null and combine those records with the ones that are null. Hope this helps, Andreas

CRM 2011 Get OptionSetValue Value through Label

Sometimes we want to be able to get the OptionSetValue value from the label itself. One way is to use the metadata request and loop through it but this is a cumbersome way. The easier way is to put those OptionSetValue data into an enum like this: We use Description Attribute for the Label so that it supports string format. Then we use this helper method: And there you go. You can easily get the value like this: Hope this helps, Andreas

Happy New Year 2012!

Image
Happy New Year everyone! May this year bring you good things and happiness! Take care, Andreas

CRM 2011 Activity Party Add, Remove, Delete from code

Sometimes we want to append the activity party list, update particular item in the existing activity party list, or remove specific activity party from the list. Below is what I discovered on how to do this. Since we can't use the Create/Update/Delete method from the service context on ActivityParty entity, we need to alter the content of the list before attaching to the Activity Field. In my case I have an ActivityRecipient custom entity that have N:1 to Email entity. Whenever the user add/update/delete this custom entity, the corresponding 'To' recipients gets updated as well. I use this function in my pre create/update/delete message of my ActivityRecipient entity. Note: for some reason Recurring Appointment doesn't like Organization Service Context (early bound), therefore we have to use IOrganizationService with Retrieve Request. Hope this helps, Andreas

CRM 2011 SMS custom activity Characters Remaining field

Paul Nieuwelaar in his blog has implemented some javascript for the characters remaining field. This saves me a lot of time from reinventing the wheel. All I then did was to set the default value to the field (160 characters for SMS). Also make sure that you put the 160 limit on the multiline textbox, but leave the minimum value for the charactersremaining field to be -20000000 to avoid the annoying message box. Hope this helps, Andreas

CRM 2011 disable lookup type for customer field or partylist

Sometimes we want to lock the lookup type for customer field type or partylist type. To do this, use the javascript (e.g. Account Type only): Hope this helps, Andreas

CRM 2011 Export Entities Tabs and Sections Name

CRM does not provide a functionality to list all your tab and section names. With the help of SQL XML parsing feature, I managed to create an sql script to read the FormXML of the entities and parse out the tabs and sections name. This is useful if you want to see all the tabs and sections that you have added. Enough said, this is the script: Hope this helps, Andreas