Skip to main content
Tweeted twitter.com/#!/StackSharePoint/status/585675982100680709
added 281 characters in body
Source Link
Luis Valencia
  • 5.2k
  • 22
  • 119
  • 219

I have a custom page that copies items from one list in one site to another, and its failing with the exception above.

I tried checking the field using sharepoint manager but I didnt find anything strange. The field where its failing its a managed metadata column the strange thing its that the exception is shown when checking if the field[internalname] is != null

  foreach (SPListItem item in listItems)
                                {
                                    SPListItem targetItem = destinationList.Items.Add();
                                    foreach (SPField field in item.Fields)
                                    {
                                        if (!field.ReadOnlyField && field.InternalName !="Attachments")
                                        {
                                            if (item[field.InternalName] != null)
                                            {
  

Update 1:

I tried these 2 ways and I still have the same error, its a managedmetadata field so no idea why its happeningn

   //if (item.GetFormattedValue(field.InternalName) != null)               
                                        if (item[field.Id] != null)

I have a custom page that copies items from one list in one site to another, and its failing with the exception above.

I tried checking the field using sharepoint manager but I didnt find anything strange. The field where its failing its a managed metadata column the strange thing its that the exception is shown when checking if the field[internalname] is != null

  foreach (SPListItem item in listItems)
                                {
                                    SPListItem targetItem = destinationList.Items.Add();
                                    foreach (SPField field in item.Fields)
                                    {
                                        if (!field.ReadOnlyField && field.InternalName !="Attachments")
                                        {
                                            if (item[field.InternalName] != null)
                                            {
  

I have a custom page that copies items from one list in one site to another, and its failing with the exception above.

I tried checking the field using sharepoint manager but I didnt find anything strange. The field where its failing its a managed metadata column the strange thing its that the exception is shown when checking if the field[internalname] is != null

  foreach (SPListItem item in listItems)
                                {
                                    SPListItem targetItem = destinationList.Items.Add();
                                    foreach (SPField field in item.Fields)
                                    {
                                        if (!field.ReadOnlyField && field.InternalName !="Attachments")
                                        {
                                            if (item[field.InternalName] != null)
                                            {
  

Update 1:

I tried these 2 ways and I still have the same error, its a managedmetadata field so no idea why its happeningn

   //if (item.GetFormattedValue(field.InternalName) != null)               
                                        if (item[field.Id] != null)
deleted 75 characters in body; edited tags
Source Link

I have a custom page that copies items from one list in one site to another, and its failing with the exception above.

I tried checking the field using sharepoint manager but I didnt find anything strange. Tthe The field where its failing its a managed metadata column

  the strange thing its that the exception is shown when checking if the field[internalname] is != null

  foreach (SPListItem item in listItems)
                                {
 
                                    SPListItem targetItem = destinationList.Items.Add();
                                    foreach (SPField field in item.Fields)
                                    {
                                        if (!field.ReadOnlyField && field.InternalName != "Attachments"="Attachments")
                                        {
                                            if (item[field.InternalName] != null)
                                        {
                                            {
                                            

I have a custom page that copies items from one list in one site to another, and its failing with the exception above.

I tried checking the field using sharepoint manager but I didnt find anything strange. Tthe field where its failing its a managed metadata column

  the strange thing its that the exception is shown when checking if the field[internalname] is != null

foreach (SPListItem item in listItems)
                            {
 
                                SPListItem targetItem = destinationList.Items.Add();
                                foreach (SPField field in item.Fields)
                                {
                                    if (!field.ReadOnlyField && field.InternalName != "Attachments")
                                    {
                                        if (item[field.InternalName] != null)
                                        {
                                            
                                            

I have a custom page that copies items from one list in one site to another, and its failing with the exception above.

I tried checking the field using sharepoint manager but I didnt find anything strange. The field where its failing its a managed metadata column the strange thing its that the exception is shown when checking if the field[internalname] is != null

  foreach (SPListItem item in listItems)
                                {
                                    SPListItem targetItem = destinationList.Items.Add();
                                    foreach (SPField field in item.Fields)
                                    {
                                        if (!field.ReadOnlyField && field.InternalName !="Attachments")
                                        {
                                            if (item[field.InternalName] != null)
                                            {
  
Source Link
Luis Valencia
  • 5.2k
  • 22
  • 119
  • 219

Value does not fall within the expected range when iterating over all fields

I have a custom page that copies items from one list in one site to another, and its failing with the exception above.

I tried checking the field using sharepoint manager but I didnt find anything strange. Tthe field where its failing its a managed metadata column

the strange thing its that the exception is shown when checking if the field[internalname] is != null

foreach (SPListItem item in listItems)
                            {

                                SPListItem targetItem = destinationList.Items.Add();
                                foreach (SPField field in item.Fields)
                                {
                                    if (!field.ReadOnlyField && field.InternalName != "Attachments")
                                    {
                                        if (item[field.InternalName] != null)
                                        {