Sage 300 SDK field values not setting ONHOLD and PRIPERCENT

Setup:

  • C# Framework: .NET Framework 4.8
  • SDK: ACCPAC.Advantage

Code Context:

OpenView just initializes a session to the DB, there would be no issues behind this - it works just fine with everything.

Important: No errors appear what so ever.


I have tried each line here, but none seem to work.

On Hold Code:

View OEORD1header = OpenView("OE0520");
OEORD1header.Compose(new View[] { OEORD1detail1, null, OEORD1detail3, OEORD1detail2, OEORD1detail4, OEORD1detail5 });

OEORD1header.Cancel();
OEORD1header.Init();

OEORD1header.Fields.FieldByName("ONHOLD").SetValue(1, true);
OEORD1header.Fields.FieldByName("ONHOLD").SetValue(1, false);
OEORD1header.Fields.FieldByName("ONHOLD").SetValue(true, true);
OEORD1header.Fields.FieldByName("ONHOLD").SetValue(true, false);
OEORD1header.Fields.FieldByName("HOLDREASON").SetValue("Your reason for on hold", false);

On Hold Context:

Trying to set the checkbox "On Hold" to true


Order Detail Discount Code:

View OEORD1detail1 = OpenView("OE0500");

OEORD1detail1.Compose(new View[] { OEORD1header, OEORD1detail8, OEORD1detail12, OEORD1detail9, OEORD1detail6, OEORD1detail7 });

foreach (SageOrderItem orderItem in order.Items)
{
    OEORD1detail1.RecordClear();
    OEORD1detail1.Fields.FieldByName("PRIPERCENT").SetValue(discountTotal, false);
    OEORD1detail1.Insert();
    OEORD1detail1.Insert();
}

Discount Context:

I am trying to have a discount value per line item, not a total order discount.

  • Your code won't work.  Record a VBA macro that does what you want, then convert that to C#.

  • 0 in reply to Jay Converse Acumen

    Hey Jay,

    Is that specific to the fields I am trying to access?

    I am able to create orders with lots of other information with no issues, customers and so forth. However I am running into this issue when it comes to two specific fields on the Order Header and Order Details.

    Thank you very much for your reply!

  • 0 in reply to Shawn

    Record a VBA macro that does what you want, then convert that to C#.

  • 0

    I use the COM api in C# but the .NET API works fine for me too.

    c# code for setting sales order on hold.

    Are you missing the OEORD1header.Insert line?

    _oeHeaderView.RecordClear();
    _oeHeaderView.RecordCreate(tagViewRecordCreateEnum.VIEW_RECORD_CREATE_NOINSERT);
    
    // set the customer
    
    _oeHeaderView.Fields.FieldByName["ONHOLD"].set_Value("1");
    _oeHeaderView.Fields.FieldByName["HOLDREASON"].set_Value("waiting for approval");
    _oeHeaderView.Insert();

  • 0 in reply to Jay Converse Acumen

    Hey Jay!

    I figure out what you meant with recording a sequence of steps and seeing which fields are for what.

    I got the On Hold working. Sadly, the Inline Discount Amount is not working as intended. "INVDISC" is for the amount according to the recorder. However, when using this field and sending a decimal, passing in "5.50" I get an error along the lines of "It must be greater than zero but less than extended amount". So when I send through ".55" it puts 55% into the Discount Percent field. And NOT the Discount Amount field like how the dang Macro Recorder says it's doing it.

    To note, "DISCPER" is the field to edit the Discount Percent field. Is this a Sage SDK flaw? Or am I missing some more magic here.

  • 0 in reply to Shawn

    We had a contractor doing an API integration last year from Sage to Magento, and here's how I told them to do complex discounting

    We can't use amounts.  What makes things work is setting the "DiscountPercentage", both at header and detail levels. So, if the raw data has a discount amount, then the equivalent percentage amount would need to be calculated and sent.

    Order Discount Payload:

    This is an $1,800 dollar order. 2 items @ $1000 = $2,000 - 10% = 1800.
    {
    "CustomerNumber": "CUST1",
    "ShipToName": "Joe Customer",
    "ShipToAddressLine1": "100 Main Street",
    "ShipViaCode": "BEST",
    "OrderDate": "2022-05-26T01:26:22.000Z",
    "OrderDiscountPercentage": 10,
    "OrderDetails": [
    {
    "LineType": "Item",
    "Item": "A1-103/0",
    "QuantityOrdered": 1,
    "OrderUnitOfMeasure": "EA",
    "PricingUnitPrice": 1000.00,
    "DiscountPercent": 0.00
    },
    {
    "LineType": "Item",
    "Item": "A1-103/1",
    "QuantityOrdered": 1,
    "OrderUnitOfMeasure": "EA",
    "PricingUnitPrice": 1000.00,
    "DiscountPercent": 0.00
    }
    ]
    }


    Item Discount Payload:

    This is a $1900 dollar order. One item is full price, the other is discounted:

    {
    "CustomerNumber": "CUST1",
    "ShipToName": "Joe Customer",
    "ShipToAddressLine1": "100 Main Street",
    "ShipViaCode": "BEST",
    "OrderDate": "2022-05-26T01:26:22.000Z",
    "OrderDiscountPercentage": 0,
    "OrderDetails": [
    {
    "LineType": "Item",
    "Item": "A1-103/0",
    "QuantityOrdered": 1,
    "OrderUnitOfMeasure": "EA",
    "PricingUnitPrice": 1000.00,
    "DiscountPercent": 10.00
    }
    {
    "LineType": "Item",
    "Item": "A1-103/1",
    "QuantityOrdered": 1,
    "OrderUnitOfMeasure": "EA",
    "PricingUnitPrice": 1000.00,
    "DiscountPercent": 0.00
    }
    ]
    }


    Order + Item Discount Payload:

    This is a $1,710 dollar order. One item is full price, the other is discounted, then 10% is taken off the top.

    {
    "CustomerNumber": "CUST1",
    "ShipToName": "Joe Customer",
    "ShipToAddressLine1": "100 Main Street",
    "ShipViaCode": "BEST",
    "OrderDate": "2022-05-26T01:26:22.000Z",
    "OrderDiscountPercentage": 10,
    "OrderDetails": [
    {
    "LineType": "Item",
    "Item": "A1-103/0",
    "QuantityOrdered": 1,
    "OrderUnitOfMeasure": "EA",
    "PricingUnitPrice": 1000.00,
    "DiscountPercent": 10.00
    }
    {
    "LineType": "Item",
    "Item": "A1-103/1",
    "QuantityOrdered": 1,
    "OrderUnitOfMeasure": "EA",
    "PricingUnitPrice": 1000.00,
    "DiscountPercent": 0.00
    }
    ]
    }