Friday, March 25, 2016

Get all unique email domain names from Microsoft Dynamics CRM database

SELECT  COUNT(*), MIN(ISNULL([ParentCustomerIdName], '')),
SUBSTRING(EmailAddress1, CHARINDEX('@', EmailAddress1) + 1, LEN(EmailAddress1) - CHARINDEX('@', EMailAddress1))
  FROM [YourCRMDatabase].[dbo].[Contact]
  WHERE EmailAddress1 IS NOT NULL
  GROUP BY SUBSTRING(EmailAddress1, CHARINDEX('@', EmailAddress1) + 1, LEN(EmailAddress1) - CHARINDEX('@', EMailAddress1))

Monday, March 21, 2016

#javascript observer pattern - using object literal notation - very simple

var obj1 = {
        for(var subIndex in obj1.subscribers)

var obj2 = {
      console.log("Obj1 changed and I was notified. I'm gonna do stuff now");


Saturday, March 19, 2016

FullCalendar remove scroll bar's header border

FullCalendar adds the following when a scroller appears:
<div class="fc-row fc-widget-header" style="border-right-width: 1px; margin-right: 16px;">

This results in a border appearing on the rightside of the header.

There's two ways to remove this inline style:
1. jQuery -  $(".fc-row.fc-widget-header").css("border-right-width", "")

2. CSS style to override
  border-right-width:0px !important;

The !important is important! That allows the CSS to override the inline style, which would otherwise take precedence.

I prefer #2, because I prefer to deal with style in CSS when possible.

Monday, March 7, 2016

Access violation exception when using dereferencing a pointer in Dex

I have a pointer point to a temp table. When I try to dereference the pointer, Dynamics GP crashes with the error: "An unhandled exception of type 'System.AccessViolationException' occurred in Dynamics.exe"

Because I was initializing the pointer in a form procedure, it was pointing to the procedure's local table buffer. When the procedure was finished, the local table buffer's memory was deallocated (). So when I dereferenced the pointer, it was pointing at nothing, hence the memory error.

Leaky abstraction
This exposes a leaky abstraction. The table buffers and memory management are abstracted away. It's not explicit that the table buffer in a procedure is different than the containing form's table buffer. Furthermore, the memory management doesn't care that there's a pointer pointing to a location in memory, it deallocates anyway. That tells me the pointers aren't really managed.

Hidden form temp table reference pattern
Instead of running into this problem again in the future, i'm going to write down the pattern for making sure this works, so i don't have to spend hours upon hours troubleshooting a leaky abstraction problem.

"Class"-like form:
1. Has one internal window called State. This window has a hidden reference field on it.
2. Form pre: set State's ref field to the table buffer
3. Init: open form if it's not opened, use the dereferenced table buffer

Thursday, March 3, 2016

Visual Studio Ctrl-F stopped finding things

Ctrl-F > typed in "thing" and Visual Studio did not find any matching values in the entire solution. I can see that there is a "thing" in the current document.

Window Menu > click Reset Window Layout

Thanks to this post from 2008!