Posts

LINQ Grouping through SelectMany - Powerful!

This is the first time I use this feature and I love it very much! What this feature does is that it flattens your object in relation to your defined selected child object. So for example, if I have a list of Item object and that object has a List  of Category  (imagine Item has N:N relationship to Category) and I want to be able to group it based on the Category and display it in such a way so it looks like this: Category 1 Item 1 Item 2 Item 3 Category 2 Item 2 Item 4 and so on.. It is easy to get that structure using LINQ! That's all you need to do! ^_^ Hope this helps, Andreas

jsRender for complex display rule

Image
Hello Everyone, So it comes to a point where I have a set of data in front of me and I want to render those data in a quick and easy way. I don't like rendering html through code behind because it is just cumbersome and hard to maintain. Also, it is not that simple to display these data because there needs to be some logic when rendering each record. This is where I thought that jsRender would be the perfect thing to use! I have used jQuery template before and  I found it quite useful but they did not continue that project. jsRender is still active in development and it is proved to be much powerful and faster (as it's claimed to be) and fortunately it is very easy to use as well. To cut things short, the sample data looks like this: Entity: CourseOutline Attribute: PathwayId (each CourseOutline can have more than 1 pathway) PathwayLineNo (1-5) EntryPoint (e.g. Year 12) Duration (duration of the Course) Product (this is the Course Product entity with Product Name...

Music Website New Look! (HTML5 & jQuery)

Image
Hello All, I am excited to say that my music website  http://pianoismyfriend.com  has been refurbished and gone live! :) I built the website by myself and it was a really good personal project and it allows me to explore all different kind of tools and technology out there. It surprised me how we can leverage variety of existing services people have to offer without reinventing the wheels these days. Some technical information about the new PianoIsMyFriend website: LightCMS is used as the hosting and the content management provider. I moved away from WordPress because of the maintenance effort comparison and the different goal that I wanted to achieve. My website should be really simple with minimal plugins. I found it hard keeping up-to-date with WordPress versions and updating my plugins that break after updating my WordPress.  With LightCMS I was able to get my website up within a week and focus more into my content and   how it fits together...

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