locked
Update "Modified on" and "Modified by" on Note creation / edit RRS feed

  • Question

  • At our company the Notes section is used quite a bit due to atachments used in our line of work.  Our cases are primarily worked in in the Notes section.  Unfortunately that does not update the "Modified on" nor the "Modified by" fields on Note creation / edit.

    Adding an OnChange() event to the notes fields does not seel to work.

    Any suggestions?

    Tuesday, April 27, 2010 5:33 PM

Answers

  • Doesn't that change by setting the workflow to Scope: Organization?

    If not, you can write a workflow activity where you can definitely set context to that of the calling user.


    Yes, the book says an Automatic Workflow always runs under the context of its creator.  So, you will have to have everyone create their own workflow ;-)

    ...or implement in plug-in or workflow activity.

     

    Or you could make the new attribute a user relationship rather than a date and update with the current user as a surrogate ModifiedBy.

    Tuesday, April 27, 2010 9:16 PM
  • I have to admit, I often overlook the power of CRM workflow engine, thanks mardukes for bringing it up, which is indeed a good solution, if Created By or Modified By is not a concern. 

    Since plug-in might be the path to go, I am offering some advice here.

    To start plug-in coding, the first code that you may look at is the <CRM SDK Folder>\server\fullsample\pluginpreaccount\ folder, it has a complete implementation accompanied by an instruction document. It's a very simple piece of code, but it will give you some idea how it works, how it should be registered, when the plug-in is invoked.

    Also the following two SDK documents (both included in the crmsdk4.chm file in the SDK package) can give you some idea how plug-in works.


    Daniel Cai | http://danielcai.blogspot.com
    Wednesday, April 28, 2010 3:15 AM

All replies

  • I don't seem to see that should be the case. Once a note record has been updated, it should show who last modified the note and when, as shown below (the second line). 

    HideNotesTitle1
    Daniel Cai | http://danielcai.blogspot.com
    Tuesday, April 27, 2010 6:48 PM
  • Are you talking about cascading a notes Modified data to the underlying Case record? 
    Tuesday, April 27, 2010 7:02 PM
  • Yes I am... so in other words you modify / create a note, then the case's Modified By and Modified On get updated with the same Modified By and Created By values as the note.
    Tuesday, April 27, 2010 7:16 PM
  • In this case, you may write plug-in code to do the job. The plug-in code should be triggered for annotation entity's Create message (Pre or Post stage, probably Post stage is better option). 

    Notes field doesn't have onchange event, but you may inspect its IsDirty property if you want to stick to JavaScript implementation, in which case, you may use JavaScript setTimeout function to check periodically if the notes field has been changed. 


    Daniel Cai | http://danielcai.blogspot.com
    Tuesday, April 27, 2010 7:29 PM
  • IsDirty does not work for the notescontrol attribute as it seems to always return false.
    Tuesday, April 27, 2010 7:45 PM
  • You are right, IsDirty property works very well for new record, but not for update form, the reason is, as soon as a note has been added on update form, it immediately posts the data to CRM server, and then IsDirty becomes false. 

    So I believe you'll have to write plug-in code, which in my opinion is a most reliable solution. 

    Cheers,


    Daniel Cai | http://danielcai.blogspot.com
    Tuesday, April 27, 2010 7:52 PM
  • Yeah that is over my head... guess I will have to get assistance on that.... Know anybody that can assist with that?
    • Edited by 41714049 Tuesday, April 27, 2010 8:18 PM I asked something silly by mistake
    Tuesday, April 27, 2010 8:14 PM
  • How about this.  Create a Date attribute on Case named, say, LadyGaga; don't expose it on any form.  Then create a workflow on Note that fires on create or change when the regarding entity is Case to stamp LadyGaga.  I haven't looked.  Can you get to the regarding case from Note in a workflow?

    Workflow on create and attribute(ModifiedOn) changed on entity Note.

    Condition, Regarding(Case).Status contains data (this is a guess as to a means of concluding that the note belongs to a Case)

    Update Regarding(Case).LadyGaga to NOW.  No DON'T update the Modified attributes.  Let the system do that.

    Now, this is asynchronous so they might not match exactly, but as Modified attributes belong to the system, I don't think you can get any closer.

    • Edited by mardukes Tuesday, April 27, 2010 8:33 PM I stepped through it
    Tuesday, April 27, 2010 8:22 PM
  • It can be done that way but what happens is since the workflow is created by me all Modified By fields that the workflow touches will be me and not the individual that performed the modification.
    • Edited by 41714049 Tuesday, April 27, 2010 8:43 PM Type-o
    Tuesday, April 27, 2010 8:25 PM
  • Doesn't that change by setting the workflow to Scope: Organization?

    If not, you can write a workflow activity where you can definitely set context to that of the calling user.

    Tuesday, April 27, 2010 9:01 PM
  • Doesn't that change by setting the workflow to Scope: Organization?

    If not, you can write a workflow activity where you can definitely set context to that of the calling user.


    Yes, the book says an Automatic Workflow always runs under the context of its creator.  So, you will have to have everyone create their own workflow ;-)

    ...or implement in plug-in or workflow activity.

     

    Or you could make the new attribute a user relationship rather than a date and update with the current user as a surrogate ModifiedBy.

    Tuesday, April 27, 2010 9:16 PM
  • I have to admit, I often overlook the power of CRM workflow engine, thanks mardukes for bringing it up, which is indeed a good solution, if Created By or Modified By is not a concern. 

    Since plug-in might be the path to go, I am offering some advice here.

    To start plug-in coding, the first code that you may look at is the <CRM SDK Folder>\server\fullsample\pluginpreaccount\ folder, it has a complete implementation accompanied by an instruction document. It's a very simple piece of code, but it will give you some idea how it works, how it should be registered, when the plug-in is invoked.

    Also the following two SDK documents (both included in the crmsdk4.chm file in the SDK package) can give you some idea how plug-in works.


    Daniel Cai | http://danielcai.blogspot.com
    Wednesday, April 28, 2010 3:15 AM