Thursday, 12 February 2015

Bind saving of an IFrame to the main Save event of a CRM Form

Hello everyone. I have been struggling with this problem for quite some time now. What I needed to do was inject an Iframe on a CRM Dynamics entity form (for example the Account form) and then save things inside the iframe by calling save or autosave on the account form. Here is a way to do this.

Wednesday, 3 September 2014

CRM Dynamics 2013: Use Ctrl+S or click the CRM ‘Save’ icon to save your custom web resource´s entities

So, you have managed to create a custom html-javascript web page which you have inserted in your CRM as described here, right? Also, your page does some database calls and updates and you would like to use the save icon, already built in CRM to submit your changes. If this is the case, read along!

Tuesday, 26 August 2014

A [Description] Attribute approach for enums in Typescript


The problem at hand is that I need to use WebAPI services to get data structured in objects and use similar objects client-side in typescript code to structure and manipulate my frontend code. In C# and WebAPI I have the option to use enums:

1 public enum SearchOption
2 {
3 [EnumDescription("Starting With")]
4 StartingWith,
5 [EnumDescription("Contains")]
6 Contains,
7 [EnumDescription("Equal to")]
8 EqualTo,
9 [EnumDescription("Not Equal to")]
10 NotEqualTo
11 }

…which is very convenient because I then could get to the “description” info by reading the attribute for the enum. In typescript on the other hand, there are enums:

Thursday, 26 June 2014

Use form properties on an external web-resource in CRM Dynamics 2013


I assume that you have read my previous post and now you would like to bind the attached web resource to some information coming from the calling form, no?
This is supported out-of-the-box in CRM Dynamics 2011 as well as in 2013, but not automatically activated. To activate this feature, you will need to edit the customizations XML file.
Go find the solution that you have been working on and export it, making sure that the customizations option is checked:
image

Add navigation items in a form view

Hello again. This time I would like to share something with regard to CRM Dynamics 2013. I was trying to add a new navigation button under an account form. So this is how you do it.


First, you go into the solution where you want to add the new customization, in my case the solution was called Tickets. I made sure the Account Entity was included into it, yet I did not bother to include its dependencies.
image

Wednesday, 18 June 2014

Switching your HDMI inputs on a Samsung TV

Hi all, let's assume that you have a Samsung TV and a Raspberry Pi connected on an HDMI input.

Using CEC you could send:
 echo "as" | cec-client -s
to switch to the next input,. However this is inconvenient since it does not switch "back" to your previous input. So what can you do?

Get this lovely utility from here. (Disclaimer: I did not write this, I got it on GitHub). It is a lovely python script which you can use to send commands to your samsung TV AFTER you have turned it on. In my case I use the commands KEY_HDMI2 or KEY_HDMI3 but there is a great variety of commands that you can send.

Keep in mind, your device (where the script will run needs to be paired with your TV in order for this to work. This can be a simple procedure, the first time you fire a command the TV asks if you would like to pair with the device, you say yes and that's all.

Python is already installed on the xBian Linux for R-Pi. So, in the same manner that I have described here, you can set up an ssh command that executes this script with python on your raspberry Pi.

Usage:
$ python samsung.py KEY_HDMI.

A more comprehensive list of commands can be found online, search google for samsung and KEY_HDMI or look for example here.

Tuesday, 25 February 2014

Make SalesLogix Remember User Specific Preferences

Hello. Today I needed to implement a little checkbox in Saleslogix with a little twist. This checkbox must remember its value according to the user that is currently using it. In other words, if a user checks this box and then closes his SLX client, the checkbox must be checked the next time the user navigates to it.
This should be – like I said – user-dependent. Every user should be able to decide in which state he / she wants to operate the checkbox.
Saleslogix offers such methods out of the box. No creation of corresponding database tables and manual manipulation of values. This is done by using the embedded Application.UserOptions methods.
Inside the OnFormChange event, we check if the values exist and if so, we set them for the current instance:
 if Application.UserOptions.Exists("hideTestCheckBox", "LicenseContact" & Application.BasicFunctions.CurrentUserID) = true then  
     hideTestCheckBox.Checked = Application.UserOptions.GetAsBoolean("hideTestCheckBox", "LicenseContact" & Application.BasicFunctions.CurrentUserID)  
 End If  
Pay attention to the “Application.BasicFunctions.CurrentUserID” modifier for the CATEGORY KEY of the UserOption. Actually, the name UserOptions is not appropriate here since these keys are actually common for all users. Thus, we need to concatenate the group key with the current user ID to avoid exceptions trying to push entries with the same Primary key in SLX DB.

(The primary key consists of the combination of the two strings inside the “Exists” statement, in our case “hideTestCheckBox” and “LicenseContact + UserID”)

In the event where the checkbox gets updated, we need to push the updated value in the User Options. This is done as such:

 Sub hideTestCheckBoxClick(Sender)  
 if Application.UserOptions.Exists("hideTestCheckBox", "LicenseContact" & Application.BasicFunctions.CurrentUserID) = false then  
   Application.UserOptions.Add "hideTestCheckBox", "LicenseContact" & Application.BasicFunctions.CurrentUserID, "Hide Test Licenses", hideTestCheckBox.Checked  
 end if  
   Application.UserOptions.SetAsBoolean "hideTestCheckBox", "LicenseContact" & Application.BasicFunctions.CurrentUserID, hideTestCheckBox.Checked, false  
   UpdateDataGrid   
 End Sub  

Obviously we need to add the key to the database in case it is not there yet. The first “IF” statement is run only once here per user. But this is mandatory, otherwise SLX throws an exception that the key is missing.

Cheers!

Friday, 10 January 2014

Force-Validate Hidden Form Fields client-side


Hello again. Let´s say you have a couple of hidden fields inside an html form and the latest version of jQuery keeps on ignoring their validation on the client side. This has been the updated default behavior after version 1.9.0. Do you need to change it? Try inserting the script below in your page that contains the form.

Friday, 20 December 2013

IIS 7 File Uploads: maximum size restricted per default

I was working on an updated way to attach files to tickets asynchronously via the Kendo Upload component. Everything was working smoothly on my development machine. I then played a local release on my own IIS. From that point on I realized that every file bigger than 30Mb that I was trying to upload was failing.
I captured the server response with fiddler, 404 page not found. How can this be? I attached the process to VS Debugger, which seemed to be working ok, but the breakpoint inside my Save() method was never hit, except for that times that I was trying to upload a smaller than 30Mb file…

Irritating huh? Well, this is what is actually going on. I found the answer on this excellent post by Web Trenches. IIS 7 limits maximum upload file size to 30Mb by default. This can however be changed and there are 2 ways to do it:

Wednesday, 18 September 2013

Updated way to include Kendo dependencies

Hello everyone, 
After spending some time doing performance testing on the MVC project it occurred to me that the quantity of data being downloaded on every request is extremely high. The reason behind this is mainly the Kendo scripts and CSS stylesheets. They were simply placed on the master layout (by me, yes, shame on me I know)​ therefore they were being loaded on every request. This is really not-so-bad since such data are being cached client-side and then retrieved from the cache, still it causes really bad performace on the first load and above all, makes the website displeasant to devices using mobile traffic.

Cascading Deletions Through Code

ModelLet´s say that you do not want to use the database way, that you have a good reason to implement cascading deletions in your code only (maybe because you have no access to the database). In this case, you need to manually remove the related entities of the object under deletion.
Let´s take the Specifications´model. The predefined relations are shown in the picture, yet, cascading has not been enabled for deletions in the SQL server for the corresponding relations. Then, you need to make sure that, when removing a specification, all its SpecificationHeaders have been removed first. Of course, each and every SpecificationHeader must have been cleared off its SpecificationItems prior to its own removal.

Here is some code to do that:

Cascading Deletions in Entity Framework

Model_thumb6Imagine that there is the model shown on the picture. You want to delete an entity of type “Specification”. There is an option called “Cascading” that can be defined under the corresponding relation between two database entries. When Cascading is on, all you need to do is simply delete the parent object. Cascading takes care of the rest, which means that it automatically clears out all related child objects.
The code that is needed comes below:


Thursday, 8 August 2013

Control your wall lights with raspberry Pi

Hello again, it´s been a while. I have decided to move on from Openelec and installed xBian on my Raspberry Pi. It all went smoothly and super fast and I am pretty happy with how it works. The reason for this decision was that Openelec has a read only file system… and I love tampering. I found a nice german guy that described a way to create a very cheap electronic expansion board and bundle it with a raspberry pi to effectively manage to control equipment such as this or this or even this. Wanna see how it`s done? Read on!

Friday, 31 May 2013

Tasker and XBMC, part 2: Create smart playlists and play them by using voice commands (UPDATED!)

Hello again everyone. I assume that you have read the previous post and will try to set up another magic trick with this one here. I will show you how to use your voice, talk to your phone and make XBMC create a playlist based on your command and actually start playing it.

Possible voice commands are for example: "Play music where album is Hairspray" or "Play music where genre is rock" or even "Play music where artist like Jason"
(Of course you need to have those in your music library, right?)

A prerequisite for all these to work is that your android phone and XBMC are connected to the same wireless network.

Friday, 24 May 2013

Tasker for android and XBMC on a Raspberry Pi: Home Automation madness

Hello back, it´s been a while. But I have been playing with interesting toys lately. And this post is here to describe some of it.

Let us introduce the toys first:
1. Tasker for android : On Android market and project website. This is an automation app for android platform. It is very easy to use, there are tutos everywhere online, I won´t cover this part.
2. XBMC on a raspberry Pi computer. If you don´t know what this is, learn. It is worth it.
3. A Samsung Smart TV (model 40UE6300).
4. Json - RPC framework. This is the way to communicate with the XBMC on the raspberry Pi and create all the magic tricks. This is just for reference, I will create another post to describe more magic tricks.
5. Autovoice plugin for Tasker. This will help you be the master of your own android device, namely by allowing you to command it. Directly.
6. Tasker SSH Command launcher.

How? Read on!

Friday, 19 April 2013

Kendo Grid: Ajax Binding while parsing Server side properties. Is this possible?


In a nutshell yes. I am currently migrating a website and I was in need of presenting data inside a Kendo Grid depending on the state of a server variable. There are different ways to achieve results, however my case was a bit peculiar. Let me first explain the goal here: We aim to be able to use .ClientTemplate templates in our Grid that actually render html based on the state of Server variables.

You might ask, why not just use the server side .Template? Simply enough, because it does not work with Ajax requests in the dataset. Please correct me if I am wrong, but no matter how hard I have tried, it never worked. So I came up with a workaround.

Monday, 11 March 2013

CSS : Create horizontally / vertically aligned elements without a table



A label is actually a -by default- inline HTML element, therefore no standardized width can be applied​ to it. Eventually this means that developers end up with elements that basically look vertically unaligned.

The solution is to add the following CSS rule on your stylesheet:

label
{
    vertical-align: central;
    display: inline-block;
    width: auto;
    min-width:90px;
    text-align: left;
}

thus, a static width can be defined and the vertical alignment can finally be fixed. I hope this helps someone.

Friday, 8 March 2013

A simple Snake Game Tutorial in C# and WPF


Introduction


My effort is to try and explain some basic concepts of programming based on really simple words and examples. This article has been posted also on codeproject

Background

The main idea behind a snake game (as in most such games)  is to "fool" the user into thinking that a series of frames is in reality a moving object. Such a concept is fabricated in my implementation. The "motion" effect is based on a series of  Timer events, each of which is "ticking" among specific intervals. The head of the snake is being drawn on a new position slightly misplaced to the direction of motion. The end of its tail is erased from our canvas, thus creating an illusion of motion.