Confirm dialog

hhhhhhhqathhhhhhhqat Member Posts: 111
you know any modify in navision is saved after modify direct ,
i have one form , we need more control for any change, i add onmodify trigger this code



IF CONFIRM('Do you confirm?',TRUE) THEN
MESSAGE('saved')
ELSE
ERROR('not saved');
EXIT;


but still even i din't confirmed and close this form it's already saved
what's the mistake i did or may be i forget something

Comments

  • kapamaroukapamarou Member Posts: 1,152
    Is the code on the OnModifyRecord() trigger of the form or on the record?

    Also, is any code executed (maybe with a commit?) before reaching your code?

    Try to debug your code step by step to see what exactly happens.
  • hhhhhhhqathhhhhhhqat Member Posts: 111
    it's onmodify trigger of the form , i just add this to give the user message to save or exit without same for any modify


    thanks
  • kapamaroukapamarou Member Posts: 1,152
    It should work... It works on my test Database... :-k

    Try the following:


    IF CONFIRM('Do you confirm?',TRUE) THEN
    MESSAGE('saved')
    ELSE
    begin
    MESSAGE('not saved');
    EXIT(FALSE);
    end;
  • hhhhhhhqathhhhhhhqat Member Posts: 111
    it's working fine now , but for some record like global dimension 1 & 2
    still no control
  • kapamaroukapamarou Member Posts: 1,152
    hhhhhhhqat wrote:
    it's working fine now , but for some record like global dimension 1 & 2
    still no control

    Can you explain this more?
  • hhhhhhhqathhhhhhhqat Member Posts: 111
    example in Employee Card i ahve Cost center (Global Dimension 1) , if i try to modify and later ignore this change it will save even i not confirmed , but other records like name , Job Title ,etc..... is OK

    should i add also in Dimension table




    thansk
  • SavatageSavatage Member Posts: 7,142
    Here's a post by Kriki that we use to confirm a change and if not return the orig value.
    kriki wrote:
    I think it is best you put it in the OnValidate-trigger of the table and not the form. Of course this means it will ALWAYS be triggered. I don't know if this is the idea.

    The code:
    IF (rec."The Field" <> xRec."The Field) and
        (CurrField = FIELDID("The Field")) THEN // this checks if the field is changed by the user and not by some other means
      IF NOT CONFIRM('Do you want to change the value from "%1" to "%2" in field "%3"?',false,
        rec."The Field",xRec."The Field,FIELDCAPTION("The Field")) THEN
        ERROR(''); // just raises an error but without message
    
    Of course it is best to use a constant instead of writing the text directly into the CONFIRM like I did.

    orig post here:
    viewtopic.php?f=23&t=35109
Sign In or Register to comment.