I am creating subsites for individual clients. In the subsites I have different lists that capture information for the client. Some of those lists would be repeating (a client might have three properties, for example), meaning that they can add items ("rows"). But other lists really only need to capture one set of information. Now, I guess I could edit the view to disable the "Add item" button, but is there a cleaner way to prevent a user from entering more than one "row" of information into a list?
As Dan suggested, it's better to use Calculated value as default:
Also, you can add this script to the NewForm.aspx:
$("[id^='Title_']").disabled = true
It will make sure the users cannot change the Title field:
Also, you can disable Quick Edit mode for the list to insure there is no easy workaround
I don't think using Workflows is an elegant solution
There are several way that you could do this. You could use an event receiver to enforce the constraint or you could use a field set to the value of the individual's user name and set it to be unique. You could do this with a workflow if you wanted a "code free" way of doing it. However, they could go back and change the value of this field.
In this case, I would likely use an event receiver as it would have fewer moving parts and could not be easily subverted but could still be disabled by an admin if required at some point.
You could add a person/group column called 'AlreadyCreatedBy'. You could set that column to require unique values. Then, enable content approval on the list. Set up a workflow that copies 'Created By' to 'AlreadyCreatedBy' and if it succeeds then set the approval status of the item to approved.
If the client, in your case, is entering in a single-row set of data, it sounds like an opportunity to make use of surveys. Surveys can be configured to allow only one submission and that can further be configured to allow edits in the future, or it can be locked down (if I recall correctly)
Have used this with SharePoint 2010:
- Column "Title" changed to calculated value "=Me"
- Created next workflow in SharePoint Designer:
- If Current Item:Title equals Current List:Title
- Delete item Current Item
Result: New entry will be created and in some seconds removed.
something easy to do is to declare a column unique, then set default value to anything and hide the column so it cant be modified by the user.