Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

The following code is throwing an ArgumentException (Value does not fall within expected range):

        var formsList = Web.Current.Lists[MemForms_Constants.MementoForm_LIST_NAME];
        var allItemsView = formsList.Views["All Items"];
        var allItemsViewFields = allItemsView.ViewFields;
        var newMasterField = formTypesList.Fields.GetFieldByInternalName(newMasterInt);

        if (null != newMasterField && !allItemsViewFields.Exists(newMasterField.InternalName))
            allItemsViewFields.Add(newMasterField);

At this point, I have confirmed that newMasterField is not null. Otherwise, I cannot deduce why it would throw this exception for a new field. I wouldn't expect it to fall in the range of valid values, since it is not there yet. Please let me know if you have any suggestions.

Thanks in advance.

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.