1

I have a custom SharePoint 2007 document library which has a custom boolean column "Is it Important".

It works perfectly for all documents if I upload documents one by one regardless of if its a word file or a picture file ".png or .jpg" as I can see property and can even access it through code.

Now if I upload files simultaneously using "multiple files upload" all documents except files with extension .png or .jpg get property "Is it Important". Now I can get value of property but if I try to check if it exists it returns false, wondering if anyone knows what could be the reason.

This is how I am checking custom property,

item.Properties.ContainsKey("Is it Important");

and getting value as

item["Is it Important"]
1

As stated problem was with

 item.Properties.ContainsKey("Is it Important");

I couldn't find out what caused this weird behaviour but I find a work around which is going through each SPField and check if my field exists or not using title.

private bool IsFieldThere(string ColumnName, SPListItem item)
{
    SPFieldCollection fieldCollection = item.Fields;

    foreach (SPField field in fieldCollection)
    {
        if (field.Title == ColumnName)
        {
            return true;
        }
    }

    return false;
}

I used title as I know it will change but you can use internal name to be on safe side.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.