Updating Sales Order Form from Sales Order Subform

headley27headley27 Member Posts: 235
I would like to update the 'Promised Delivery Date' field on the Sales Order Form when the 'Promised Delivery Date' on any line of the Sales Order Subform is greater than the former date.

I would be triggering this from the 'Promised Delivery Date' field on the Sales Order Subform.

I have a few variables named that I realize aren't 100% necessary but they are there to help me figure this out.

mySalesHeader - Sales Header Record
mySalesLineDate - Promised Delivery Date of Active Sales Line
mySalesHeaderDate - Promised Delivery Date of Sales Header

Promised Delivery Date - OnAfterValidate()

mySalesHeader.GET("Document Type","Document No.");

mySalesLineDate := Rec."Promised Delivery Date";
mySalesHeaderDate := mySalesHeader."Promised Delivery Date";

IF mySalesLineDate > mySalesHeaderDate THEN BEGIN
**** What Goes Here To Update the Sales Order Form (and inevitably the Sales Header Table) ****
END;

Thank you, :?:
headley27

Comments

  • HalMdyHalMdy Member Posts: 429
    Directly : no way


    Have a look at http://www.mibuso.com/forum/viewtopic.php
  • HalMdyHalMdy Member Posts: 429
  • headley27headley27 Member Posts: 235
    Thank you HalMdy.

    This works with one problem.

    If the Sales Order Subform has focus the following message appears when I try to Update the Sales Order Form.

    Another user has modified the record for this Sales Header after you retrieved it from the database.

    Enter your changes again in the updated window, or start the interrupted activity again.

    Identification fields and values:

    Document Type='Order',No.='30119'
    This is the code started by the OnTimer event.

    lSalesLine.SETFILTER("Document No.", Rec."No.");
    IF lSalesLine.FIND('-') THEN
    REPEAT
    IF lSalesLine."Promised Delivery Date" > lPromisedDate THEN
    lPromisedDate := lSalesLine."Promised Delivery Date";
    UNTIL lSalesLine.NEXT = 0;
    Rec."Promised Delivery Date" := lPromisedDate;
    CurrForm.UPDATE;

    How do I get around this?

    Thanks again,
    headley27
  • headley27headley27 Member Posts: 235
    I tried this code and it works.

    CurrForm.UPDATE;
    lSalesLine.SETFILTER("Document No.", Rec."No.");
    IF lSalesLine.FIND('-') THEN
    REPEAT
    IF lSalesLine."Promised Delivery Date" > lPromisedDate THEN
    lPromisedDate := lSalesLine."Promised Delivery Date";
    UNTIL lSalesLine.NEXT = 0;
    Rec."Promised Delivery Date" := lPromisedDate;
    CurrForm.UPDATE;

    Adding the first CurrForm.UPDATE fixed the problem.
    Why though is beyond me.

    Thanks again.
    headley27
Sign In or Register to comment.