inserting an order header optional field

SOLVED

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.

  • 0
    verified answer

    I found my issues - none of which were in the code provided above.   I had a typeo in defining the view compositions which broke the tie between views.   In addition, there was an issue when I called the last .Process (like of the orders view).   I removed that and all was fine.