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?
Comments
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);
Thank you for replying.
However, where should I put these codes, since I could not call the CurrForm in the Codeunit?
Andwian
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;
I will try and let you know how it goes. Thank you!
Andwian