Sales Order Release inconsistent

spider1269spider1269 Member Posts: 73
I'm seeing an issue with Sales Orders when they are released by code. I'm creating a Sales Order through code and then releasing it using the standard release function but sometimes the orders won't calculate the Amount field in the Sales Line or Sales Header. Has anyone seen this before?
ReleaseSalesDoc.PerformManualRelease(SalesHdr)

Comments

  • DenSterDenSter Member Posts: 8,307
    The Amount field on the sales header is a flowfield. If you are releasing the order in code, you will need to do a CALCFIELD on the Amount field to update the value in code. On a form/page you don't have to do this in code because the form/page object will do that for you.
  • spider1269spider1269 Member Posts: 73
    That's already being done. What will happen is I'll go to the Sales Order List and the Amount field there will say $0 and all the line items will show $0 as the amount even though the order is released.
  • SavatageSavatage Member Posts: 7,142
    I'm creating a Sales Order through code

    are you validating all the necessary fields?
  • spider1269spider1269 Member Posts: 73
    That's the odd thing. If I manually release it it's fine. Even when I release it through code it will work 80% of the time.
  • DenSterDenSter Member Posts: 8,307
    Sounds to me like someone modified the release codeunit, maybe put a commit in there somewhere, commented out an error message, put some code on the form/page or something like that.

    You need to figure out what happens differently during the 20% that it doesn't work, and debug those instances. Steps to recreate is your first priority, recreate a situation where it always goes a certain way. What is different about an order that releases properly and one that doesn't. You're in trouble if the same order has two different results in two subsequent release attempts.
  • spider1269spider1269 Member Posts: 73
    Thanks Denster! You put me on the right path. I found code from 5 years ago that skipped the UpdateUnitPrice function only under certain conditions.
  • DenSterDenSter Member Posts: 8,307
    Hey I'm glad to hear you figured it out, love those AHA! moments :mrgreen:
Sign In or Register to comment.