Hi Simon,
That helped quite a bit. Interestingly it didn't like the "MyDoc = GetDocumentFromSelfRelation();" bit at all because it generated an error saying: "CS0103: The name 'GetDocumentFromSelfRelation' does not exist in the current context" so I just commented it out and (after correcting some other errors) it compiles properly.
A couple of notes about the sample code in
the kb article:
1. It didn't like ItemChoiceType.Text for the table columns that are Text but it does seem to like ItemChoiceType.String
2. it doesn't like it when you pass the value of a Decimal field without quotations around it
However, when I run it it says "Object reference not set to an instance of an object." and I've paired the web method back to the basics to see if I can figure out what's going on but I can't, so, much as I hate posting the code itself, I can't think of anything else to do:
//get the document
MyDoc = GetDocumentFromFileCabinetById(conn, "<CabinetGUID>", DocId);
//MyDoc = GetDocumentFromSelfRelation();
DocumentIndexFieldTable tableField = (DocumentIndexFieldTable)MyDoc.Fields.FirstOrDefault(f => f.FieldName == "GL Account Distribution").Item;
//make the code field
DocumentIndexField codeField = DocumentIndexField.Create("GL_AC_CODE", "Test Code");
codeField.IsNull = false;
codeField.ItemElementName = ItemChoiceType.String; //set the itemchoicetype according to what kind of field it is
//make the amount field
DocumentIndexField amountField = DocumentIndexField.Create("GL_AC_AMOUNT", "10.00");
amountField.IsNull = false;
amountField.ItemElementName = ItemChoiceType.Decimal; //set the itemchoicetype according to what kind of field it is
//make the description field
DocumentIndexField descriptionField = DocumentIndexField.Create("GL_AC_DESCRIPTION", "Test Description");
descriptionField.IsNull = false;
descriptionField.ItemElementName = ItemChoiceType.String; //set the itemchoicetype according to what kind of field it is
//creates a new table row and adds the existing field. If you have more than one column, create more fields like the first one and add to this list
DocumentIndexFieldTableRow newField = new DocumentIndexFieldTableRow() { ColumnValue = new List<DocumentIndexField>() { codeField, amountField, descriptionField } };
// when done with adding fields to the row, add the row to the table field
tableField.Row.Add(newField);
//Due to reference types we can just take the fields list
//from original provided document object
DocumentIndexFields updatedTableIndexFields = new DocumentIndexFields()
{
Field = MyDoc.Fields
};
MyDoc.PutToFieldsRelationForDocumentIndexFields(updatedTableIndexFields);