SmartObject Method Error

  • 23 August 2011
  • 3 replies
  • 0 views

Badge +4

I'm getting an error on one of my SmartObject methods. The method is a "Read" type, and looks up a SharePoint document library item. I'm mapping the data I receive back to new fields in the SmartObject.


The error is:



Server was unable to process request. ---> Message: String was not recognized as a valid Boolean.Couldn't store <No> in CMS_x002d_13 Column. Expected type is Boolean.; ServiceName: Hospital; ServiceGuid: 1f39d5e8-3626-4e2b-b72d-3ad7f5c126f8; InnerExceptionMessage: String was not recognized as a valid Boolean.;


The field itself is defined as a Choice field. I have verified this in the document library settings as well as it being in the HTML output of the SharePoint page when editing an item in the list.



<!-- FieldName="CMS-13"
FieldInternalName="CMS_x002d_13"
FieldType="SPFieldChoice"
-->


To add injury to insult (and I know why this is happening technically), the CMS-13 field isn't even one of the columns I'm interested in :-s


Any ideas on how to resolve, workaround this issue? Thanks in advance for your time in reviewing this and any responses.


K2 blackpearl 4.5 (4.10060.1.0) with update KB001140


3 replies

Badge +10

Hi,


It seems as though your Hospital Service Broker is returning <NO> instead of false. Could it be that you are allowing multiple selections? Maybe because of multiple values which can be entered, the column comes back with the brackets around them. I guess you can try changing it to a single value select.


A workaround: I would use an Inline function to search for the <NO> or <YES> and then return true or false based on what it finds. The "IF" inline function will work rather nicely. You will simply drop this inline function into the column which should accept the result and then have the conditional check the field from the Hospital service. The return type will be boolean and you can use the "True" and "False" inline functions to return the correct boolean value.


I'm not sure exactly when Inline functions were introduced into the product, it might be that your K2 version is too old and that you do not have this. If the Inline functions (Fx) tab does not appear in the K2 Object Browser then your version of K2 does not support this yet and you will need to upgrade. I know for a fact that version KB1170 and above supports it, but I'm not sure about KB1140.


Hope this helps!

Badge +4

Thanks for the suggestion Johan, unfortunately even if in-line functions were supported I don't believe this would be an available option for me (please correct me if I'm wrong). The inference that the Service Broker is making to columns is incorrect. In other words, the K2 SharePoint Service (SourceCode.SmartObjects.Services.SharePoint.SharePointService) is the service I am using to get the list item information.  The column giving errors converting is not available to the Hospital Service at development time (Exist in Production but not in Dev). This column was added "after the fact", in the production environment (See "Side Note" below).


The troublesome SharePoint column type contains the following attributes



  • Type: Choice (menu to choose from)
  • Information Required: Yes
  • Choice Options: No, Yes, Maybe
  • Display Choices Using: Drop-Down Menu
  • Allow 'Fill-in' choices: No
  • Default Value: Choice

I've packed a good bit of information into this so if I need to expand on something let me know.


Site Note: I will say that we give our site owners (site collection administrators) full authority to add/remove what they please, to accommodate their needs. We have approximately 100+ sites that this same K2 process lives on so it would be difficult to imagine this issue being an isolated case. Please save the "what are you thinking!!!". It's SharePoint we're talking about. So far I've found it impossible to treat SharePoint lists as tables and keep the users away from access to them (and in most cases modifying the "table structure"). Granted this is not a technical limitation but a business decision.

Badge +4

Simple solution (big thanks to Conrad).


Refresh The SharePoint service instance using the SmartObjects Services Tester tool.  I did update the service instance value to point to the problem SharePoint site.

Reply