Update Status on the Header part of a Sales Order form

liizzliizz Member Posts: 125
Hello all,

I have a card-form which is based on Header and Line.

On Sales Line form, I have kept a field Status which has the option values: Partly and Closed.
Also, I have this field on the Header part too.

For a particular Order No., I have several lines with Status Partly and Closed.
On the Sales Order form, if I validate the all Status on the Line to be Closed, then the Status of the Header part should be Closed.

For e.g: Sales Line part
1) Document No.: S0001
Line 1:
Item A - Status: Partly
Line 2:
Item B- Status: Closed
Status on Header: Partly

2) Document No.: S0002
Line 1:
Item A - Status: Closed
Line 2:
Item B- Status: Closed
Status on Header: Closed

Can somebody please give some help. I am stuck on it.

Thanks
Liizz

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Check Completely Shipped field in Sales Header table as reference..
  • liizzliizz Member Posts: 125
    Check Completely Shipped field in Sales Header table as reference..

    There is no code on this field on table 36.

    Thanks
    Liizz
  • liizzliizz Member Posts: 125
    Hi.

    Thanks Mohana.

    But the field Status is not getting updated on the Header part. I am trying the example you told me.


    This is the piece of code which is updating the Status for each Lines for that particular Document No.
    RecLine.SETRANGE("Document No.","Document No.");
    RecLine.SETFILTER("Qty Del",'>%1',0);
    IF RecLine.FINDSET THEN
    REPEAT
    IF (RecLine."Qty Del"<>RecLine.Quantity) THEN BEGIN
    RecLine.Status:=RecLine.Status::"Partly";
    RecLine.MODIFY;
    EXIT;
    END ELSE IF (RecLine."Qty Del"=RecLine.Quantity) THEN BEGIN
    RecLine.Status:=RecLine.Status::Closed;
    RecLine.MODIFY;
    END;
    UNTIL RecLine.NEXT=0;

    RecLine: record variable.

    If all the Status from the Lines are closed, then Status on Header =Closed
    else Status on Header=Partly

    Please help me.. ](*,)

    Thanks
    Liizz
  • SavatageSavatage Member Posts: 7,142
    Doesn't the "Completely Shipped" field give you the same information?
    why are you reinventing the wheel?

    Do you see:
    Sales Header: Completely Shipped (5752) Type Boolean
    Flowfield
    Min("Sales Line"."Completely Shipped" WHERE (Document Type=FIELD(Document Type),Document No.=FIELD(No.),Shipment Date=FIELD(Date Filter),Location Code=FIELD(Location Filter)))

    Sales Line: Completely Shipped (5752) Type Boolean

    It's value is calc'ed on Quantity - OnValidate()

    if "Qty Del" is your custom field.
    If you want to copy that functionality to a new fields called "Completely Delivered" then follow how "Completely Shipped" Works and you'll probably have to calc the value on your "Qty Del" - OnValidate.

    You'll see you don;t need all that code. and what trigger is all that code on anyway?
  • liizzliizz Member Posts: 125
    edited 2012-07-19
    Hi.

    I have placed these codes on a Submit button, each lines is getting updated.
    liizz wrote:

    RecLine.SETRANGE("Document No.","Document No.");
    RecLine.SETFILTER("Qty Del",'>%1',0);
    IF RecLine.FINDSET THEN
    REPEAT
    IF (RecLine."Qty Del"<>RecLine.Quantity) THEN BEGIN
    RecLine.Status:=RecLine.Status::"Partly";
    RecLine.MODIFY;
    EXIT;
    END ELSE IF (RecLine."Qty Del"=RecLine.Quantity) THEN BEGIN
    RecLine.Status:=RecLine.Status::Closed;
    RecLine.MODIFY;
    END;
    UNTIL RecLine.NEXT=0;

    RecLine: record variable.

    But, on the Sales Line there is no codes on the Quantity-OnValidate() where CALCFIELDS is being used.

    Yes, I have also defined a Boolean field as u mentioned.
    Min("Custom Lines"."Completely Delivered" WHERE (Document No.=FIELD(No.),Status=FIELD(Status)))

    But still, its not working. The Status is not being changed accordingly
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Remove Status from flowfield calculation..add only fields which are linking header and line..
  • liizzliizz Member Posts: 125
    Ok.

    But where should I use the CALCFIELDS functionality?

    Thanks
    Liizz
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    If you need it in form the simply add the field in form..
    if in report then need to use CALCFIELDS..
  • liizzliizz Member Posts: 125
    I need it on a form.

    Please can u be a bit more clear in what u mean.
    If you need it in form the simply add the field in form..

    Thanks
    Liizz
Sign In or Register to comment.