Those little CRM hacks worth avoiding

One of of my colleagues came across an interesting scenario when trying to re-activate an activity. Out of the box CRM does not include a  “re-open” or “re-activate” button on activity records.

We could write some code to add an “activate” button onto activity entity forms so when a user presses it the activity is re-opened. An alternative is to create a workflow to run on-demand that re-opens the record.

Whilst investigating the above she stumbled across an interesting blog which shall remain unnamed.

It advises you to use the below JavaScript in the CRM URL, on the completed activity to re-open it:

“–javascript: var form = $(“iframe”).filter(function () { return ($(this).css(‘visibility’) == ‘visible’) })[0].contentWindow;form.Mscrm.CommandBarActions.activate(form.Xrm.Page.data.entity.getId(), form.Xrm.Page.data.entity.getEntityName());”

This works but the first worry that comes to mind is – How is this affecting the database?

SQL

Having created a test appointment in CRM, the system sets in SQL the statecode to 3 (Scheduled) and the statuscode to 5 (Busy) on creation.

If we close the appointment as “Completed”, the system sets the statecode to 1 (Completed) and the statuscode to 3 (Completed) on update.

If we then re-open the appointment using the script above, the system sets the statecode to 0 (Open) and the statuscode to 1 (Free) on update.

Finally if we then close the appointment again as “completed”, the system sets the statecode to 1 (Completed) and the statuscode to 3 (Completed) on update.

From our testing it looks like the JavaScript re-opens the appointment slightly differently to when an appointment is first created. I am not saying this doesn’t work but I am saying you should probably avoid little tricks like this, especially on customers live systems!

Stick to using the supported functionality such as workflows to prevent stumbling across potential data corruption in CRM unless you are feeling very confident!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s