Page 1 of 1

Call to SPGetFieldValue returns 0 on invalid FieldName.

Posted: Thu Aug 24, 2017 7:04 pm
by at2k21
Making a call to SPGetFieldValue passing "" or even "nonsense" for chFieldName parameter returns 0 as the result. According to the documentation it should return a result < 0. Has this changed and not been updated in the documentation? Is there a way to know if a field name is invalid compared to a valid one that has an empty string as the value?

Re: Call to SPGetFieldValue returns 0 on invalid FieldName.

Posted: Mon Aug 28, 2017 8:48 am
by Gil McNeill
The documentation is wrong for that function. SPGetFieldValue returns the length of the data in the field. If you pass in a bad field name it will return zero. I'll put a bug in to get that fixed so that the API returns < 0 value for a bad field name.

SPSetFieldValue (on the other hand) will return an error if you pass in a bad field name.You will get a -104 error code in that scenario.