Skip to main content
1-Visitor
April 30, 2013
Question

Testing whether document has changed

  • April 30, 2013
  • 5 replies
  • 2282 views
I'd like to be able to test in ACL whether a document has changed. Putting it another way, if the user closed the document, would they be prompted to save?

Thanks.


Jonathan Reeve
Practical Law Company






This e-mail from Practical Law Company (

    5 replies

    1-Visitor
    April 30, 2013
    You can do this with the modified() function.

    if (modified(current_doc())) {
    # Do something
    }
    else {
    # do something else
    }

    You can also use this function to set modified to 'false' to disable the prompt before closing

    modified(current_doc(), 0);

    Chris

    1-Visitor
    April 30, 2013
    Chris,

    I believe the if statement needs to have an '=="1" for it to work.

    This would only work as the document is being closed though. Once the
    document is saved, Epic would not know if the document had been modified or
    not (unless change tracking were turned on and you wanted to test for some
    value in that).

    Jonathan, Epic automatically lets the author know if the file is modified.
    In the message bar in the lower right, you'll (or the author) will see a
    "MOD" (Epic using the modified function) and Epic will ask if you want to
    save the file on closing.



    Though with Chris's code, you can force the save.



    Lynn


    1-Visitor
    May 1, 2013
    Lynn,

    ACL doesn't have a boolean data type, just strings and integers; thus for locations where other languages would test a boolean, ACL tests whether a value is the number 0, the string "0", or the empty string, ", all of which evaluate as 'false'; everything else is treated as 'true'. So while "if (modified(doc) == 1)" would also work, the "==1" is unnecessary, since modified() returns 0 (false) if the document is not modified.

    And, yes, once the document is saved, modified() will return 0. What modified() tests is whether the document contains changes that have not yet been serialized to disk via a save. I took that to be the point of the question. Apologies, if I misunderstood the question.


    1-Visitor
    May 1, 2013
    The modified function was what I wanted. I have an alias that connects up an ACL function to handle close events, and I wanted to know if the user would be prompted to save, so that I could make sure that some things had been done before saving.

    Thanks for you help, Chris and Lynn.
    1-Visitor
    May 1, 2013
    Chris,



    Thanks, being more a document editor with a bit of programming experience, I
    wasn't aware of that. I'll give it a try in one of my scripts when I get a
    chance.



    Lynn