Answered by:
Making 1 out of 2 fields Required in a SharePoint List

Question
-
I have a SharePoint List with 2 Users (People or Groups) Columns...
I want to make 1 out of 2 Required, that is, users filing out a New list form should put value in either 1 of 2 Users field...
Is there any way to achieve that...
Thanks.. Any idea would be appreciated..
Wednesday, March 30, 2011 9:48 PM
Answers
-
Hi,
If i understand correct you have 2 columns, and at least one of them needs a value. If this is correct you could solve the problem with an eventreceiver using the event itemadding see this link for details:
I'll give you a nice tip, the itemadding event is a bit tricky the way it uses data. You are in the process of adding data so the entered data is not yet added to the listitem. That is why you need to access the properties! This is nicely explained here:
http://koenvosters.wordpress.com/2009/07/31/howto-create-an-event-handler-for-sharepointmoss-2007/
HTH!
- Marked as answer by Peng Lei Friday, April 8, 2011 1:40 AM
Thursday, March 31, 2011 5:56 AM -
Hi,
According to your description, I suggest that you should set the SPFieldLink that relates to that field to be required. I have found a useful blog about programmatically making a Field Required in SharePoint 2007, please refer to:
http://www.novolocus.com/2010/10/28/programmatically-making-a-field-required-in-sharepoint-2007/
please have a try.
Best Regards
David Hu- Marked as answer by Peng Lei Friday, April 8, 2011 1:40 AM
Friday, April 1, 2011 1:41 AM
All replies
-
Hi,
If i understand correct you have 2 columns, and at least one of them needs a value. If this is correct you could solve the problem with an eventreceiver using the event itemadding see this link for details:
I'll give you a nice tip, the itemadding event is a bit tricky the way it uses data. You are in the process of adding data so the entered data is not yet added to the listitem. That is why you need to access the properties! This is nicely explained here:
http://koenvosters.wordpress.com/2009/07/31/howto-create-an-event-handler-for-sharepointmoss-2007/
HTH!
- Marked as answer by Peng Lei Friday, April 8, 2011 1:40 AM
Thursday, March 31, 2011 5:56 AM -
Hi,
According to your description, I suggest that you should set the SPFieldLink that relates to that field to be required. I have found a useful blog about programmatically making a Field Required in SharePoint 2007, please refer to:
http://www.novolocus.com/2010/10/28/programmatically-making-a-field-required-in-sharepoint-2007/
please have a try.
Best Regards
David Hu- Marked as answer by Peng Lei Friday, April 8, 2011 1:40 AM
Friday, April 1, 2011 1:41 AM