locked
User input from plug-ing? RRS feed

  • Question

  • Is it possible to get additional information from the user during the plugin execution. 

    I am creating an auditing plugin and it is working quite well, but it would be even better if for the delete function, if I could request a reason for the deletion from the user (e.g. duplicate contact, company out of business, etc)

    Even a free-text box where they could put some details would be helpful.

    I can't seem to find any information related to this anywhere else, so hopefully someone here can help

    Thanks
    Thursday, March 26, 2009 6:28 PM

Answers

  • You cannot actually alert the user directly from the plugin, to do so you would have to develop your own "Delete" complete with an aspx page (similar to the dialog you get when you close an opportunity) that would ask the user for a reason. It can be done and there are good examples around on how to do just that.

    However, in your case, consider this alternative solution:

    - You add a "Delete" value for status reason to your entity.
    - You disable deletion (by removing it from the privileges)
    - The only way a user has to delete the object is tthen by setting the status reason to "Delete"
    - You can run Javascript at that point on the OnSave that captures the actual reason.
    - You save the actual reason in a field of the object.
    - Your plugin (Which I suppose runs on the Update event as well) checks for the status reason. If the status reason is "Delete" it actually deletes the record and enters the deletion reason in the audit record.
    - Saves you a lot of development, and requires only a little training for the users.

    • Marked as answer by wndrbear Monday, March 30, 2009 3:12 PM
    Thursday, March 26, 2009 8:35 PM

All replies

  • You cannot actually alert the user directly from the plugin, to do so you would have to develop your own "Delete" complete with an aspx page (similar to the dialog you get when you close an opportunity) that would ask the user for a reason. It can be done and there are good examples around on how to do just that.

    However, in your case, consider this alternative solution:

    - You add a "Delete" value for status reason to your entity.
    - You disable deletion (by removing it from the privileges)
    - The only way a user has to delete the object is tthen by setting the status reason to "Delete"
    - You can run Javascript at that point on the OnSave that captures the actual reason.
    - You save the actual reason in a field of the object.
    - Your plugin (Which I suppose runs on the Update event as well) checks for the status reason. If the status reason is "Delete" it actually deletes the record and enters the deletion reason in the audit record.
    - Saves you a lot of development, and requires only a little training for the users.

    • Marked as answer by wndrbear Monday, March 30, 2009 3:12 PM
    Thursday, March 26, 2009 8:35 PM
  • Thanks Alberto,

    That was pretty much my conclusion as well, but I'm new to plugin coding and I just wanted to make sure there wasn't a way that would "exactly" what I want.  I had already thrown the idea of the status reason around in my head, and your information helped me solidify my musing.

    Much appreciated.
    Monday, March 30, 2009 3:12 PM
  • If a user does not have the permission to delete, they will not be able to delete.  Are you planning to override that in the plugin?  If so, this can open a fairly large hole where users who really don't want to delete will be able to if they go directly to your custom page.
    Ascentium | www.ascentium.com | www.rosslotharius.com
    Monday, March 30, 2009 8:42 PM
    Moderator
  • Ross/Wndrbear,

    Thanks for the observation, but the idea is to have a workflow to do that. I always forget to specify "workflow" when I talk about custom code. What I meant was a "plugin" that is actually a "custom workflow activity".

    What I have done in a very similar situation is to have the workflow delete the object when the status is "Delete". The workflow is triggered by the status change, and it can run with an identity that has rights to delete your entities.

    So Wndrbear, you can mix and match between plugin and workflow, but I always tend to use as much OOTB as possible: if you use a status of "Delete" to signal the desire to delete an object, then a workflow (i.e. somebody else) can actually do that.

    Tuesday, March 31, 2009 12:26 AM