Quick tip: custom lists are a great way to store data about a business process or operation that doesn’t necessarily fit in a standard list. They can be used to store virtually any type of data, that makes sense in list form. For instance, you might record the configuration details of all the switches on your network. They’re especially helpful in that by enabling versioning on a list, you can create an audit trail of when things changed. Critically, though, when something changes, you’re likely to want to know why. Therefore, when someone changes an item, you might want to insist that they add a comment to quickly describe the change they have made, and why.
It’s easy to enable this basic functionality.
1. On your List, enable Versioning. Optionally set how many versions should be kept – this will also limit the number of comments you see in the list.
2. Create a new field called “Comments” of type “multi-line text“, select “Require that this column contains information” and finally the kicker “Append changes to existing text” should be set to Yes.
3. Save and go back to your list and create and edit a new item.
You’ll see that when you now edit an item, any previous comments have been automatically removed from the Comments box – and you are forced to enter a comment before you can save it. You can see comments about a specific version by going to the version history.
* Slight caveat, there seems to be a bug when using “edit in datasheet” – the current comment isn’t always removed and therefore you’re not always prompted. Indeed, this is no different to a human bug- that is, if this is really mission critical, then you’ll need a workflow in the background to validate the entry to ensure the comment added is actually meaningful.



for
Tip: infopath comments and newline textbox
Tuesday, April 26th, 2011One method for persisting data in a SharePoint environment is the use of Infopath forms. Infopath stores data in your form in XML format. I have a form which has a “comments” box where people add new comments as they progressively update the form and a “consolidate comments” box which shows all previous comments*. However, Infopath forms don’t natively support appending new data to existing data – and new comments added may blow away any previous comments.
It’s relatively trivial to enable this functionality. Assume you have your two comment boxes
comments_add – blank comment box for adding new comments
comments_display – shows all historical comments, and is bound to your “comments” field in your data connection
button_submit – submits the form to the server, will currently have rules, e.g., “submit using data connection”, “close form”
To add new comments to old comments, you need to add a rule to your button, before the data is submitted. The rule will “set a field’s value” and use the concat function to concatenate the two comments boxes together. In the value section, Insert Formula and have, e.g
In this case I set the value of my local “comments” field to the value of “ows_comments” (in my data connection) + the value of my new comments box. When you submit this, your comments box will contain both values. However, you will notice that the display is not very nice. You could concat a space in between the fields, but a newline between comments would be preferable. This is not quite as simple as it sounds, however, as Infopath controls don’t seem to accept the standard newline chars (e.g., \r\n). There is a way, however:
1. Create a new XML file and fill it with
<linebreaks>
<newLine>
</newLine>
</linebreaks>
2. Add it as a resource and data connection to your form
3. In your Concat function, reference it:
4. Ensure your textbox is multi-line enabled (Click Textbox > Control Tools > Control Properties)
And that should work. I had screenshots of the process, but it seems an overzealous host admin has gone crazy with mod_security2 and killing anything that tries to add an equals sign to a post.
Tags: comments, infopath, newline, SharePoint
Posted in SharePoint | 8 Comments »