locked
Highlight Changes in a Field in a Data View Web Part (DVWP) RRS feed

  • Question

  • Hi! I have been searching endlessly for a way to highlight specific changes that have occurred in a SharePoint (2007) List using a DVWP. Here is the scenario:

    Users update project information in a SharePoint List. Let's say there are Title, Accomplishments, and Plans columns. On a weekly basis, each user updates their project status.

    There is a separate web page that contains a Data View Web Part that combines all the different project information and displays it in a report-style format. What I want to do is be able to highlight any changes that have occurred since the user last edited their project status. For example, let's say we have on week 1:

       Project: X
       Accomplishments: Did stuff.
       Plans: Do a whole bunch of stuff.

    Then, on week 2, the user changes the "Accomplishments" field but leaves "Project" and "Plans" alone:

       Project: X
       Accomplishments: Did this other stuff that was way different.
       Plans: Do a whole bunch of stuff.

    While I turned on version tracking in SharePoint and can tell that there was a change to the entire item (entry), I can't figure out how to highlight specific changes (i.e. conditional formatting) for certain fields. In this case, I'd like the Accomplishments to turn blue (shown in bold), as that was the updated field:

       Project: X
       Accomplishments: Did this other stuff that was way different.
       Plans: Do a whole bunch of stuff.

    Is there any way to do this? Is there a way to have the DVWP display a specific version/revision of the field other than the most current?

    Any help is appreciated. Thanks!





    • Edited by sgmustadio Monday, March 19, 2012 11:28 PM
    Monday, March 19, 2012 11:26 PM

Answers

  • Unfortunately, this is pretty complicated.  Any time I need to do this type of thing in a workflow, such as send an email when a specific field changes, I have to basically create "copy of" fields for all of the fields that I want to track.  Duplicate fields.  Then, when an item is changed, the workflow looks to see if the field is equal to its copy.  If it is not, then an email gets sent or whatever, letting someone know that the field was changed, and then the next step is to set the "copy of" field to have the same value as the change that was just made. 

    I'm not sure how this type of thing could be done in a dvwp as you describe.  I think it would still require creating copies of all the fields, but then you'd also have to have some sort of indicator that the conditional formatting would be based off of.  Very tricky.  Sorry.


    Laura Rogers
    SharePoint911: SharePoint Consulting
    Blog: http://www.sharepoint911.com/blogs/laura
    Twitter: WonderLaura
    Books:Beginning SharePoint 2010: Building Business Solutions with SharePoint
    Using InfoPath 2010 with Microsoft SharePoint 2010 Step by Step

    Tuesday, March 20, 2012 3:51 AM
  • Genius! The "duplicate" fields got me thinking. I can create two additional hidden fields for each field. We'll call them prev_field and field_flag. On modification of an item, a workflow will check to see if field == prev_field. If so, then field_flag is set to 0, otherwise, set field_flag to 1 and copy field to prev_field. Pseudo code looks like this:

    if (field == prev_field) {
      field_flag = 0;
    } else {
      field_flag = 1;
      prev_field = field;
    }

    Now, whenever the report is run, if the field_flag for that field is 1, use conditional formatting to highlight it blue. Bingo! Thank you!!!! :D

    Tuesday, March 20, 2012 3:05 PM

All replies

  • Unfortunately, this is pretty complicated.  Any time I need to do this type of thing in a workflow, such as send an email when a specific field changes, I have to basically create "copy of" fields for all of the fields that I want to track.  Duplicate fields.  Then, when an item is changed, the workflow looks to see if the field is equal to its copy.  If it is not, then an email gets sent or whatever, letting someone know that the field was changed, and then the next step is to set the "copy of" field to have the same value as the change that was just made. 

    I'm not sure how this type of thing could be done in a dvwp as you describe.  I think it would still require creating copies of all the fields, but then you'd also have to have some sort of indicator that the conditional formatting would be based off of.  Very tricky.  Sorry.


    Laura Rogers
    SharePoint911: SharePoint Consulting
    Blog: http://www.sharepoint911.com/blogs/laura
    Twitter: WonderLaura
    Books:Beginning SharePoint 2010: Building Business Solutions with SharePoint
    Using InfoPath 2010 with Microsoft SharePoint 2010 Step by Step

    Tuesday, March 20, 2012 3:51 AM
  • Genius! The "duplicate" fields got me thinking. I can create two additional hidden fields for each field. We'll call them prev_field and field_flag. On modification of an item, a workflow will check to see if field == prev_field. If so, then field_flag is set to 0, otherwise, set field_flag to 1 and copy field to prev_field. Pseudo code looks like this:

    if (field == prev_field) {
      field_flag = 0;
    } else {
      field_flag = 1;
      prev_field = field;
    }

    Now, whenever the report is run, if the field_flag for that field is 1, use conditional formatting to highlight it blue. Bingo! Thank you!!!! :D

    Tuesday, March 20, 2012 3:05 PM