I am trying to insert an optional field for a new sales order. When I run the macro recording I get some code and have ported that to C#. The issue is, it did not seem to work.
ordersView.Process();
ordersView.Fields.FieldByName("PROCESSCMD").SetValue("1", false);
orderHeaderOptFieldsView.RecordClear();
orderHeaderOptFieldsView.RecordGenerate(false);
orderHeaderOptFieldsView.Fields.FieldByName("OPTFIELD").SetValue(optionalField.Name.LocalName, false);
bool needsInserted = orderHeaderOptFieldsView.Read(false);
orderHeaderOptFieldsView.Fields.FieldByName("AC").SetValue("myACValue, false);
if (needsInserted)
orderHeaderOptFieldsView.Insert();
else
orderHeaderOptFieldsView.Update();
orderHeaderOptFieldsView.Process();
ordersView.Process();
ordersView.Insert();
The issue is, when I run it, nothing happens. No error or anything. Note the order does get created But no optional field row is created in the database (note I am using SAMINC and assured that the optional field is there and available.