Monday, January 9, 2012

MSCRM change record owner (Assign) Javascript


MSCRM change record owner (Assign).

How to add JavaScript to owner change:
On create form - It's not an assign event yet, just had OnChange event to the owner's control on the form and the code will run.
On update form - This is trickier, because every time the owner changes the OnChange event won't fire and instead thee save event is fired on the form. In order to catch it with JavaScript add code to the OnSave event.
var SAVED_MODE_ASSIGN = 47;
function onSave(ExecutionObj)
{
     if(ExecutionObj.getEventArgs().getSaveMode() == SAVED_MODE_ASSIGN)
    {
           //Do something after record assigned
    }
}



The good and the bad of how to tackle the problem:
JavaScript:
The same way I've just presented.
The Good: Easy to add code (JS), The users will see the results straight a way.
The Bad: it won't run when user assigning owner from the grid, youy needs to know JavaScript.

Proccess - Workflow
Create new Process and set it to fire on "Record is assigned".
It's async and the user will see the results of the process only after few seconds.
The Good: Easy to implement, the process will work after all assign event no matter where the user perform them.
The Bad: The user will see the result only after few seconds and it's limited to process capabilities.

Plugins
Create new plugin on event - Assign.
Write done the logic or get someone do to it for you.
The Good: Works any way you want it to and in any condition you want.
The Bad: You'll needs to know how to write plugins. Takes a bit more time (It's done outside the CRM)

Sunday, January 1, 2012

MSCRM 2011 depended optionset

There is no need to create something that is already there.
There is a very good (generic) solution for depended optionset (picklist) in the SDK.

The problem is it's technical solution, That's mean you'll probably need developer next to you when you do it the first time. 

Maybe I'll create GUI for it one day. :)