Not allow to modify a record in some conditions

albertbuiguesalbertbuigues Member Posts: 7
edited 2020-12-17 in NAV Three Tier
trigger OnValidate()
var
StatusLbl: Label 'The status of the policy has changed to: %1', Comment = '"ESP = "El estado de la póliza ha cambiado a: %1"';
begin
Rec.Reset();
// --- IF para comprobar si el estado de la póliza es Aceptada o Rechazada ---
if (("Policy Status" = "Policy Status"::Approved) OR ("Policy Status" = "Policy Status"::Rejected)) then
Message(StrSubstNo(StatusLbl, "Policy Status"));
Rec."Accep. Reject. Date" := Today();
Rec.Modify(false);
end;

This is my code. I want to not allow to modify antithing of the record if I enter in the IF section. How can I do it?

Answers

  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from 'NAV Tips & Tricks' forum to 'NAV Three Tier' forum]

    Instead of using a Message, use an Error.
    PS: for both Message and Error, you don't need to use StrSubstNo.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • lubostlubost Member Posts: 627
    Probably you have to change your code to:
    if (("Policy Status" = "Policy Status"::Approved) OR ("Policy Status" = "Policy Status"::Rejected)) then begin
    Message(StrSubstNo(StatusLbl, "Policy Status"));
    Rec."Accep. Reject. Date" := Today();
    Rec.Modify(false);
    end;
Sign In or Register to comment.