Posts

JQuery & Knockout - A Simple Example

Image
Hi All, I have been assigned to do some client side stuff. In this case, we have some FAQ contents in CRM back-end and I want to  grab those content and display it in a user control. End result will look like this: We extensively use Knockout.js and jQuery in terms of displaying simple content. The advantage of this is that it renders much faster than using server controls. To grab the data we can use POST request to get JSON from the asmx webservice. Here is an example of displaying FAQCategory. Note that: 1. UPDATE - updated to knockout 2.1.0 . This will use native templating. 2. Grouping is achieved by creating pivot 'associative' array object :) 3. Notice multiple synchronous request? This is because the webservice is using RetrieveMultiple request (CRM 4.0) thus I need to grab attribute from related entity. Then I append the attributes to my result object. (can use FetchXML but more cumbersome in terms of parsing + slower than QueryExpression. Also, you can ...

New Songs - Blooming Or Withering Flower

Image
Which one suits your mood? :) Enjoy, Andreas

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