How to refresh the form?

AndwianAndwian Member Posts: 627
I want to make the Whse. Shipment created after Function | Create Whse. Shipment automatically Released, with these code:

Codeunit 5752 Get Source Doc. Outbound\CreateFromSalesOrder(SalesHeader)
...
  IF WhseRqst.FIND('-') THEN BEGIN
    GetSourceDocuments.USEREQUESTFORM(FALSE);
    GetSourceDocuments.SETTABLEVIEW(WhseRqst);
    GetSourceDocuments.RUNMODAL;
    GetSourceDocuments.GetLastShptHeader(WhseShptHeader);
    FORM.RUN(FORM::"Warehouse Shipment",WhseShptHeader);

// Add these lines:
    IF WhseShptHeader.Status = Status::Open THEN
      ReleaseWhseShipment.Release(WhseShptHeader);
  END;

After I get back to the Whse. Shipment, the Whse. Shipment actually released, but the form shown Open, thus I have to Refresh it to change it to Release.

How do I can change the Status without having the user to refresh the form?
Regards,
Andwian

Comments

  • mrsamrsa Member Posts: 35
    You can try something like this:

    CurrForm.UPDATE(FALSE);
    REc.GET(rec that you ned)
    CurrForm.UPDATE(FALSE);


    or i use somtime and some more crazy code:

    CurrForm.UPDATE(FALSE);
    IF rec.findfirst THEN
    CurrForm.UPDATE(FALSE);
    REc.GET(rec that you ned)
    CurrForm.UPDATE(FALSE);
  • AndwianAndwian Member Posts: 627
    mrsa wrote:
    CurrForm.UPDATE(FALSE);
    REc.GET(rec that you ned)
    CurrForm.UPDATE(FALSE);
    

    Thank you for replying.

    However, where should I put these codes, since I could not call the CurrForm in the Codeunit?
    Regards,
    Andwian
  • mrsamrsa Member Posts: 35
    You acctuale release docuemnt after creating shipment, you can put some global falg in 5752 codeunit like (releaseWhseShipment boolean), call funcion in sales oreder button to set it to true and put some code to release document in 5752 codeunit like:


    CreateFromSalesOrder(SalesHeader : Record "Sales Header")
    WITH SalesHeader DO BEGIN
    TESTFIELD(Status,Status::Released);
    CheckLocation(TRUE);
    WhseRqst.SETRANGE(Type,WhseRqst.Type::Outbound);
    WhseRqst.SETRANGE("Source Type",DATABASE::"Sales Line");
    WhseRqst.SETRANGE("Source Subtype","Document Type");
    WhseRqst.SETRANGE("Source No.","No.");
    WhseRqst.SETRANGE("Document Status",WhseRqst."Document Status"::Released);

    IF WhseRqst.FIND('-') THEN BEGIN
    GetSourceDocuments.USEREQUESTFORM(FALSE);
    GetSourceDocuments.SETTABLEVIEW(WhseRqst);
    GetSourceDocuments.RUNMODAL;
    GetSourceDocuments.GetLastShptHeader(WhseShptHeader);

    // Add these lines:
    IF releaseWhseShipment THEN
    IF WhseShptHeader.Status = Status::Open THEN
    ReleaseWhseShipment.Release(WhseShptHeader);

    FORM.RUN(FORM::"Warehouse Shipment",WhseShptHeader);
    END;
    END;
  • AndwianAndwian Member Posts: 627
    I understand that we have to do the Release, and then run the Whse. Shipment.

    I will try and let you know how it goes. Thank you!
    Regards,
    Andwian
Sign In or Register to comment.