Onaftergetrecord

PeterGouw
Member Posts: 4
Dear All,
I have these script below in Onaftergetrecord, but the message are appear after all record has completely processed.
Any suggestion why it is happened?
====================================================================
Window.UPDATE(1,"No.");
gVar_Skip := FALSE;
// Validation
gRec_SL.SETRANGE(gRec_SL."Document No.", "No.");
gRec_SL.SETRANGE(gRec_SL.Type, gRec_SL.Type::Item);
IF gRec_SL.FINDFIRST THEN
BEGIN
REPEAT
IF (gRec_SL.Quantity > 0) THEN
BEGIN
IF gRec_SL."Quantity Invoiced" = gRec_SL.Quantity THEN
BEGIN
// only for Released SO
IF Status <> Status::Released THEN
BEGIN
MESSAGE('Status SO %1 bukan Released!',"No.");
gVar_Skip := TRUE; // 2 april 2015
END;
// only for Released SO
END;
END;
UNTIL gRec_SL.NEXT = 0;
END; // Validation
IF gVar_Skip = FALSE THEN
BEGIN
///
/// PROCESSES IF VALID
/// PROCESSES IF VALID
///
END
I have these script below in Onaftergetrecord, but the message are appear after all record has completely processed.
Any suggestion why it is happened?
====================================================================
Window.UPDATE(1,"No.");
gVar_Skip := FALSE;
// Validation
gRec_SL.SETRANGE(gRec_SL."Document No.", "No.");
gRec_SL.SETRANGE(gRec_SL.Type, gRec_SL.Type::Item);
IF gRec_SL.FINDFIRST THEN
BEGIN
REPEAT
IF (gRec_SL.Quantity > 0) THEN
BEGIN
IF gRec_SL."Quantity Invoiced" = gRec_SL.Quantity THEN
BEGIN
// only for Released SO
IF Status <> Status::Released THEN
BEGIN
MESSAGE('Status SO %1 bukan Released!',"No.");
gVar_Skip := TRUE; // 2 april 2015
END;
// only for Released SO
END;
END;
UNTIL gRec_SL.NEXT = 0;
END; // Validation
IF gVar_Skip = FALSE THEN
BEGIN
///
/// PROCESSES IF VALID
/// PROCESSES IF VALID
///
END
0
Comments
-
Messages are put in message queue and "displayed after the C/AL code is finished executing or after the C/AL code pauses to wait for user interaction".0
-
Hi,
What are you using this code on? Form, page or report?
Also try and avoid nested begin end statements so you could replace
{
IF (gRec_SL.Quantity > 0) THEN BEGIN
IF gRec_SL."Quantity Invoiced" = gRec_SL.Quantity THEN BEGIN
// only for Released SO
IF Status <> Status::Released THEN BEGIN
MESSAGE('Status SO %1 bukan Released!',"No.");
gVar_Skip := TRUE; // 2 april 2015
END;
// only for Released SO
END;
END;
}
with
if (gRec_SL.Quantity > 0) and (gRec_SL."Quantity Invoiced" = gRec_SL.Quantity) and
(Status <> Status::Released) then begin
MESSAGE('Status SO %1 bukan Released!',"No.");
gVar_Skip := TRUE; // 2 april 2015
end else gVar_Skip := false;
Neil0 -
I am using report object for this process.0
-
Hi,
Then that's the issue as identified by Luc re message displayed at the end of the report processing data.
Presume you do not want the message really so why not add a counter instead and display the count at the end to confirm the process is working?
Something like:
Window.UPDATE(1,"No.");
gVar_Skip := FALSE;
//fpc090415
clear(TrueCount);
clear(FalseCount);
//fpc090415
// Validation
gRec_SL.SETRANGE(gRec_SL."Document No.", "No.");
gRec_SL.SETRANGE(gRec_SL.Type, gRec_SL.Type::Item);
IF gRec_SL.FINDFIRST THEN BEGIN
REPEAT
if (gRec_SL.Quantity > 0) and (gRec_SL."Quantity Invoiced" = gRec_SL.Quantity) and
(Status <> Status::Released) then begin
//fpc090415
//MESSAGE('Status SO %1 bukan Released!',"No.");
//fpc090415
gVar_Skip := TRUE; // 2 april 2015
//fpc090415
TrueCount:=TrueCount+1;
//fpc090415
end else begin
gVar_Skip := false;
//fpc090415
FalseCount:=FalsCount+1;
//fpc090415
end;
//fpc090415
{
IF (gRec_SL.Quantity > 0) THEN BEGIN
IF gRec_SL."Quantity Invoiced" = gRec_SL.Quantity THEN BEGIN
// only for Released SO
IF Status <> Status::Released THEN BEGIN
MESSAGE('Status SO %1 bukan Released!',"No.");
gVar_Skip := TRUE; // 2 april 2015
END;
// only for Released SO
END;
END;
}
//fpc090415
UNTIL gRec_SL.NEXT = 0;
END; // Validation
IF gVar_Skip = FALSE THEN
BEGIN
///
/// PROCESSES IF VALID
/// PROCESSES IF VALID
///
END
Neil0 -
Actually, we need the message to appear as soon as the record is read and processed.
But, since it is the natural behavior of Navision, I suppose there is nothing I could do, is there?
Many thanks to Luc and Neil.0 -
Hi
Sorry no.
Neil0 -
You can use CONFIRM (have both Ok, Cancel do nothing) or make your own Form which can be opened instead of a message screen.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions