Search code examples
dynamics-crm-2011dynamics-crm

How to capture QueueItem Release datetime in CRM 2011


I have added a "Released On" field in Queue Item form and on the click of "Release" button on ribbon I would like to capture the current date time in that field. Also, when we click "Release" button on ribbon, a confirmation popup window opens up. Could it be possible to disable that popup window as well.

In order to capture the current datetime stamp I have added a javascript function as a webresource and tried to add this js function as a command on Release button using Ribbon Workbench but that didn't work. Probably my approach is not correct or I am doing something wrong. Please suggest.


Solution

  • First, consider what releasing a QueueItem actually does. In a nutshell it's just clearing out the workerid field. If you're always going to release queueitems from the queueitem form javascript should work by checking if the workerid field does not contain data. If it's empty, write the date.

    Odds are, however, you're going to release the queueitem from other places in CRM like the queue view or advanced find which both have the release button on them. In these cases javascript will not work because it only triggers when you're releasing from the queueitem form itself.

    A better option is to write a plugin with a PreImage that triggers on update of a queueitem record in the Pre-Operation stage. Because plugins trigger any time a pre-determined message executes against an entity, the plugin will always trigger no matter where your release is initiated from.

    When a queueitem is updated: if the PreImage's workerid field contains data but the record in its current state does not contain data then you know it's been released. In this scenario write the current date into your new custom field.