This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

The script could not be executed because the maximum number of nested scripts was exceeded

Hello guys,

For the context : I would like to know who was the last person who changed a certain property.

For this, I created an Event Handler (AfterSetProperties) where I get my current user and check if the property was changed based on its previous version

Fullscreen
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

When i'm testing the script, I'm getting this error : 

  • AfterSetProperties::DocumentTestModifiedBy, 36, The script could not be executed because the maximum number of nested scripts was exceeded. (0x80040969)

I've already checked the execution order : https://www.m-files.com/user-guide/2018/eng/execution_order_of_scripts.html and i'm pretty sure that's the event handler i need to use.

Any help will be very appreciated Slight smile

Thank you very much
Claudio - EVOK - Altern8 SA

  • It is possible to increase the maximum number of scripts in Advanced Vault settings, but be careful and only increase in modest numbers if you are absolutely certain that is what you need. Otherwise you may allow the server to run endlessly if your scripting leads to a loop.

    I have not checked your code for errors!

  • It looks as if the following statement:

    Vault.ObjectPropertyOperations.SetProperty ObjVer, propValLoggedUser

    will cause an endless loop because this row of code will trigger the same event.
    In order to prevent endless loops there is such a mechanism. Changing this configuration of the server is highly dangerous.
    Maybe you should think about setting up an external log file.

  • Your statement seems completely logical to me however it is contradictory compared to the official documentation of M-Files which indicates:

    The event handlers are executed when the property values of the object stored in the document vault are re-set. Properties can be inspected during BeforeSetProperties before they are set. It is not, however, recommended to modify properties during BeforeSetProperties as they may be overwritten after the event handler has been executed. Properties, on the other hand, can be modified during the AfterSetProperties event.

    Available Event Handlers

    If you have any recommandations on this, i'll take them :)

  • Hi Claudio_Leitao,

    If I understood your idea correctly, you want to support an Employee who last changed something in the document. I have no idea how you can isolate a property and keep track of who changed it. But in general it can't happen the way you started, because as I said, it causes an endless cycle. I enclose a script that can give you some ideas

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hello everyone, 

    At the end, I proposed the client to send him an email or write the "Modified by User"  into a log file.
    Like said, the followed statement : Vault.ObjectPropertyOperations.SetProperty ObjVer, propValLoggedUser --> Creates an inifnite loop.

    Thanks one more time to for his contribution :)

  • Perhaps a bit late, but have you tried running your script in an 'BeforeCheckInchangesFinalize' Event Handler?

  • Hey there,

    I think i've tried it, and didn't work.