0

I am trying to update an object (Generic List object) to RuntimeFiledCollection. When I try to update using the following code, I am getting always Serialization error :(

//My object which need to update set with the documentRuntimeField value
List<docInfo> docInfoList = new List<docInfo>
docInfo = new docInfo { ID = "11233", PageNumber = 1, text ="MyOwnText"};
docInfoList.Add(docInfo);

// Construct DOcument RuntimeFields Collection
var docRunTimeCollection = new CaptureDocumentService.RuntimeFieldCollection();
var docRunTimeField = new CaptureDocumentService.RuntimeField 
{ Name = "FieldName", Value = docInfoList };
docRunTimeCollection.Add(docRunTimeField);
captureDocumentServiceClient.UpdateDocumentFieldValues(sessionId, null, validDocumentId, docRunTimeCollection);

I always get sterilization error as shown below. Can someone give me an example how to update document field values with an object. Any help ?

Error : There was an error while trying to serialize parameter http://www.kofax.com/agilityservices/sdk:runtimeFields.InnerException message was System.Collections.Generic.List

ktaSharp
  • 27
  • 7

1 Answers1

1

For RuntimeField class, you can see the the Value property is of type Object, but that is misleading, because it is not an arbitrary container. It takes the type that you defined for that field in your Extraction Group. But essentially that just means it will take a DateTime for a Date field or numeric types for a Number field, and anything else would be casted to string.

If you actually using a Table Field, then you cannot use the API to set the contents of the entire table. You would instead set the RuntimeField.TableRow and RuntimeField.TableColumn properties to use the API to set individual cells.

Stephen Klancher
  • 1,374
  • 15
  • 24
  • Hi Steve, You are correct. The value property of type Object is misleading. Thank you very much for the clarification. Just wondering do you have any example code to set list of table values to RuntimeField collection. – ktaSharp Jul 10 '21 at 18:09
  • I don't, but it's just calling the API in a loop, where you are are setting RuntimeField.TableRow and RuntimeField.TableColumn, and then Value is the value of the Cell, not the whole table. – Stephen Klancher Jul 17 '21 at 00:25