locked
Audit log RRS feed

  • Question

  • Hi,

    I have an IFD CRM 4.0 where contacts can login and update their telephone numbers etc.
    The 'Home phone', 'Business phone' and 'Mobile phone' are displayed in textboxes on a FormView with a Update Button.

    On Click of the Update Button the new values are updated to the contact.
    As an audit log, I am also creating a letter (activity), with the relevant contact as the regardingto, and I am storing all the textbox values in the body of the letter.

    I am struggeling to also log the previous values (before the changes was made) in the body of the letter.
    So On_Click all the values of the textboxes (whether they were changed or not) and previous values should be stored in the letter.

            TextBox strMobilePhone = FormView1.FindControl("txtMobilePhone") as TextBox;
            TextBox strBusinessPhone = FormView1.FindControl("txtBusinessPhone") as TextBox;
            TextBox strHomePhone = FormView1.FindControl("txtHomePhone") as TextBox;
            TextBox strEmailAddress = FormView1.FindControl("txtEmailAddress") as TextBox;
          
            string strDescription = ("Portal user: " + Profile.UserName.ToString() + Environment.NewLine +
                "Reference key: " + Profile.RefKey.ToString() + Environment.NewLine +
                "Mobile phone: " + strMobilePhone.Text + Environment.NewLine +
                "Business phone: " + strBusinessPhone.Text + Environment.NewLine +
                "Home phone: " + strHomePhone.Text + Environment.NewLine +
                "Email address: " + strEmailAddress.Text);    
    
            // log the change of contact details in a activity type letter
            letter logContactDetails = new letter();
            logContactDetails.subject = "Log - Contact details updated: " + Profile.UserName.ToString();
            logContactDetails.description = strDescription;
            logContactDetails.regardingobjectid = new Lookup();
            logContactDetails.regardingobjectid.type = EntityName.contact.ToString();
            logContactDetails.regardingobjectid.Value = contactGuid;

    Logging the new values works just fine....but how can I get the old values into the same letter?

    Regards

    Monday, March 12, 2012 10:57 AM

Answers

  • Hi

    We do it all the time  and this is in Crm 4.0 the way you do is

    1) Write the Plugin for Update Message

       within that you compare the PreEntittyImage and PostEntityImage

     if  ((postImage.Properties.Contains("fullname")) && (preImage.Properties.Contains("fullname"))
    )   {
         if   (postImage.Properties["fullname"].ToString() !=pretImage.Properties["fullname"].ToString())
        { 
           //-- Record Audit
                  
                }
      }

    hth

    dkay

     if the response answered your question, please take a minute and mark the response as an answer.

    • Marked as answer by Basquiat Tuesday, March 13, 2012 10:17 AM
    Monday, March 12, 2012 11:52 AM

All replies

  • Hi,

    You can try the below.

    1. Write a post update plug-in for contact entity.

    2. Move the logger code to the plug-in.

    3. Get the old & new values in plug-in using plug-in IMAGES

    4. Create a letter with old/new changes (for audit)

    Thanks

    Regards

    Gopi.R

    Monday, March 12, 2012 11:21 AM
  • Hi

    We do it all the time  and this is in Crm 4.0 the way you do is

    1) Write the Plugin for Update Message

       within that you compare the PreEntittyImage and PostEntityImage

     if  ((postImage.Properties.Contains("fullname")) && (preImage.Properties.Contains("fullname"))
    )   {
         if   (postImage.Properties["fullname"].ToString() !=pretImage.Properties["fullname"].ToString())
        { 
           //-- Record Audit
                  
                }
      }

    hth

    dkay

    Monday, March 12, 2012 11:52 AM
  • Hi

    We do it all the time  and this is in Crm 4.0 the way you do is

    1) Write the Plugin for Update Message

       within that you compare the PreEntittyImage and PostEntityImage

     if  ((postImage.Properties.Contains("fullname")) && (preImage.Properties.Contains("fullname"))
    )   {
         if   (postImage.Properties["fullname"].ToString() !=pretImage.Properties["fullname"].ToString())
        { 
           //-- Record Audit
                  
                }
      }

    hth

    dkay

     if the response answered your question, please take a minute and mark the response as an answer.

    • Marked as answer by Basquiat Tuesday, March 13, 2012 10:17 AM
    Monday, March 12, 2012 11:52 AM
  • Thanks for the replies.

    I'll give it a try. I am not that familiar with CRM plugins and was hoping that I could get the values from the same DataSource used to bind the FormView's textboxes

     

    Monday, March 12, 2012 12:17 PM
  • Hi

    Did this help?

    Please make sure to mark as answer to the response that helped you get through. This will help others with similar problem identify the answer and also close this thread as resolved.

    Thanks

    Dkay

    Monday, March 12, 2012 8:53 PM
  • Thank you ...I might be back for more help with the plugin.

    I would have hoped that a plugin would not be necessary...that one could get the values in the website from the DataSource.

    Tuesday, March 13, 2012 10:19 AM