Web service drops integer fields values

Using web services to create a library document creates the record but puts NULL values in fields that are integers (IDs and filesize). I confirmed that the IDs are valid and tried passing them as integers and strings with the same results. Any ideas

Dim MyEWBase As CRM_WS.ewarebase()
ReDim MyEWBase(1)
Dim newEntry As New CRM_WS.library()
newEntry.filepath = strpath & "\"
newEntry.filename = strFile
newEntry.companyid = intComp
If intPers > 0 Then newEntry.personid = intPers
newEntry.type = "Report"

newEntry.caseid = intCase
newEntry.status = "Final"
newEntry.global = "N"
newEntry.filesize = intSize
newEntry.mergetemplate = "N"
newEntry.note = "Auto created from email from " & strFrom
MyEWBase(0) = newEntry
Dim aresult As CRM_WS.addresult

aresult = binding.add(SH, "Library", MyEWBase)
Dim newLibID As CRM_WS.crmid


newLibID = aresult.records(0)

  • 0

    Hi,

    You'll find that all the variable types that are structs (int, boolean, datetime and so forth) have a matching boolean property called 'XXXXSpecified'. So you should find a property of the Library object called 'companyidSpecified', which you need to set to true. Same with the other id fields.

    In case you - or anyone else - is interested as to why this is so, it's because these primitive types can't be null, and have default values. The 'specified' flag is a way of knowing whether a parameter has really been passed between the client and the server.

    For example : an integer value - if not explicitly passed - would still have a default value of zero. So how do you differentiate between a value that is zero simply by default and a one that was deliberately passed with a zero? If the 'specified' flag is set then the value is passed across (even if it is zero). If not, then the value isn't passed at all.

    (Personally I'd prefer it if the WSDL defined these fields as nullables - int?, bool? etc, but there you go)