Thursday, July 24, 2008

What 'Extra' you would like to see in MS CRM ?


what is that you feel Titan still lacks,
any particular feature that you think will enhance
MS CRM's usability, will make it more popular,
more powerful compared to other CRM products?

Compare modified values on Save


What if you want know whether a field is modified when you click on Save in CRM entity record form, it is simple, check the IsDirty property of the field, as in

if( crmForm.all.field.IsDirty == true) ...

what if you wanted to compare the modified value with the original value that was on Load when you click on Save, a pre-update callout/plugin seems to emerge as a candidate, but you can also do it through clientscript, all you need to do it so find a way to store the value of the original value of the field on Load and use it in your On Save script.

An obvious choice would be to use a hidden field, but for that we have to keep a spare attribute in the entity schema which means it will add an extra column to the entityExtensionbase table in CRM database, just to store a temporary value, doesn't sound good.

What we can do as an alternative is save it in a temporary html element that can be generated on-the-fly just when the form Loads, see how it is done:

On Load script:

initial_value = crmForm.all.field.DataValue;

var new_element = document.createElement('INPUT');

var outertext =
" < input type='hidden' " +
" id='temp_tag' value=' " +
initial_value +
"' />";

var idval = "temp_tag";
var typ = "hidden";

var tagId = document.createAttribute('id');
var tagType = document.createAttribute('type');

var outerHtml = document.createAttribute('outerHTML');



This will add a new hidden element on the form when it loads, and it contains the value of your field, once you are done modifying it, you click on Save, you check whether it has been edited and compare it with the old value:

On Save script

var new_value = crmForm.all.field.DataValue;

//And you get the old value from the element you created on load
//Apparently, the element that you added is the last to be added to the form, hence you can retrieve it as the last element in the document's tag list

var element_array = document.getElementsById('input').length
var count = document.getElementsById('input').length;
var your_element = element_array[count-1];

//Now you have your element, read it's outerHTML property that contains your old value

var old_value = your_element.outerHTML;

//Please note that you get a tag and not the actual value in this outerHTML, so you have to do some string operation to retrieve it in its purest, non-adulterated form

// In my case, I split the tag string with single quote, returning an array of strings, just find out which place is your value, it was at position 5 in my case.

old_value = old_value.split("'")[5];


Now you have the new value as well as the old value, use it for any validation logic you want.

Wednesday, July 23, 2008

Assign values to Readonly fields


When you set a field to be read only in entity form editor, it is not possible to set any values to it even through Javascript apart from front-end, in such cases we may consider an option not to keep it Read Only and just enable-disable it in Form Load and Form Save scripts.

But going for a temporary solution has its cons, the way a field appears when it is Readonly and when it is disabled are different, disabled field looks grey, while readonly looks white, just like another editable field.

But there is a way to keep it read only and still able to set value to it, just after you set value to the readonly field in your script, turn the ForceSubmit property on:

crmForm.all.field.DataValue = "some value";

crmForm.all.field.ForceSubmit = true;

Friday, July 11, 2008

Timestamp for each entity custmization

Hi Friends,
Is there any way by which we can find out when an entity was
last custmized, yes there is...

One way is to access the MS CRM database through a safe and secure way, find out the modified date of entitybase tables and display them on a custom page, this way you can keep track of when entity in customized that gives you better idea of who and when customized an entity in a shared development environment,
I am still finding a way to do the same using SDK or through Javascript.

Welcome everyone

Hello friends,
so you are here to read some dynamics crm stuff,
be assured then, you've landed in the right place