Veröffentlicht Wed, 28 Jul 2021 19:13:34 GMT von Jon Weston File IT Solutions Sr Application Developer and RIM specialist
Hi all,

I'm using a c# web service to write an amount a decimal field in a table and it works great except for when the decimal field has been left blank and is therefore null, in which case it generates an error that says something like "unable to update XML document".  Unfortunately, the whole point of this web service is to give the user the option to leave that field blank so the web service can do a bunch of calculations and fill it in for them - I could default the field to zero and tell the users that they're allowed to leave it as zero, but I'd rather shoot for the more intuitive solution of letting them leave it blank (for the users, seeing a zero in there could cause problems).

The error occurs at this point in the code:
//Set for single entry a new price
				columnIndexFieldAmount.Item = 30m;
If the field is NULL it throws an error.  Are there some adjustments I can make that will allow it to write to a NULL decimal field?
Veröffentlicht Fri, 30 Jul 2021 06:25:43 GMT von Fabian Kall - left 01.22
Can you check the reference to columnIndexField in a debugger? I vaguely recall that empty table fields erroneously appear to hold DocuWare's Date value.

I solved it like this:

// row is the table row I want to edit. There is a decimalField that may or may not be empty.
row.ColumnValue.Remove(decimalField);  // This actually is not void, I believe, but in my case I don't need the result.
List<DocumentIndexField> cells = row ColumnValues;  // holds all cells except the one I want to update.
var myDecimalValue = someFancyCalculation();  // my new Decimal value;
cells.Add(DocumentIndexField.Create(decimalColumnName, myDecimalValue); // decimalColumnName holds the Name of the column
// all above is done in a loop over the existing rows of the tablefield
// I also have a variable newRows of type List<DocumentindexFieldTableRow>, so now I can do:
newRows.Add(new DocumentIndexFieldTableRow() { ColumnValue = newRows } ;
DocumentIndexFieldTable newTable = new DocumentIndexFieldTable();
newTable.Row = newRows;
DocumentIndexField newTable = new DocumentIndexField()
                    {
                        FieldName = orginalTableFieldName,
                        ItemElementName = ItemChoiceType.Table,
                        Item = newRows
                    };

                    DocumentIndexFields updatedTableIndexFields = new DocumentIndexFields()
                    {
                        Field = new List<DocumentIndexField>() { newTable }
                    };
                    document.PutToFieldsRelationForDocumentIndexFields(updatedTableIndexFields);

Basically You use the old table to completely construct a new Table and update the table on the document just as you would any other Indexfield.

Sorry for the terrible formatting.
 

Sie müssen angemeldet sein um Beiträge in den Foren zu erstellen.