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

back again with a strange issue. Using powershell I can get a handle on a SPListItem and do Item["My Field"] which prints its value.

However, in a C# custm workflow activity, when I attempt to do this exact same thing on the exact same ListItem I get an error stating: Value does not fall in expected range. I have also tried Item.GetFormattedValue which does not work. I tried the field.title, as well as field.internalname for both methods.

At first I figured the variable I was assigning it to was wrong or that since this particular field was a boolean it could not be converted to a string. (Can't remember which language doesn't allow this). At any rate, I decided to do a dump of all available fields and their values. Turns out, another field of the exact same type (Yes/No) was working 100% fine! Since this is using content types, I also checked to ensure that the field belonged to the content type of the item in question and it does. I can't think of any other reason this would happen except that the value was blank. So I unchecked it, still no dice, and re-checked it which didn't work.

Please help!

EDIT:
Added code below


   #Powershell code that worked
   $web = $site.OpenWeb()
   $itm = $web.getListItem("path to folder")
   Write-Host $itm["DisplayVerboseLogging"] #Yes/No field
   #Outputs correct value - True
   Write-Host $itm["IsDefault"] #Yes/No field (same settings as above)
   #Outputs correct value - True

   //previously declared string log;
   //Visual Studio (C#)
   SPWeb web = site.OpenWeb();
   SPListItem item = web.GetListItem("path to folder");

   log += item["DisplayVerboseLogging"].toString();
   //Throws value not in expected range error.

   log += item["IsDefault"].toString();
   //Does not throw exception. log gets proper value - True
share|improve this question
1  
Can you post the code you're using? –  RJ Cuthbertson Jul 23 '13 at 21:32
    
Added code above @RJCuthbertson –  Realistic Jul 25 '13 at 14:54

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.