You would add this in the page you’re opening, not in the code that opens the page. What is the intent you’re trying to produce? I assume that in a page you’re wanting to know if the page is in add mode vs edit. Correct? To accomplish this you’d add something such as a crt.HandleViewModelResumeRequest on the page and check the cardstate there.
Thanks Ryan, I'm also try using crt.HandleViewModelResumeRequest, but nothnig happens.
What I need is that when I open the page "Air Equipment/NdosPage_3ud8c3e" it can detect if I am working with a new record and do something. So it is in the code of this page, where I enter the commented code, compile, open an existing record and create a new one and the code entered does not execute/does not work in any situation.
If I add the code inside a crt.HandleViewModelAttributeChangeRequest, it works, but it stays
in loop and to exit I have to go back in the browser.
I made a short video to show what I'm doing and where the code is in case it helps to understand, see at