I'm overriding the HandleViewModelAttributeChangeRequest request handler in client code, and want to set a hidden parameter used for showing/hiding fields and making them required/not required in this code when the page first loads, but I don't want this change to be detected by Creatio as a save-able change so that it thinks there is a change to be saved when closing the page. Is it possible to do this? I've tried setting the "silent" property of the request to true in the HandleViewModelAttributeChangeRequest handler and also tried setting the "IsChanged" property of the request.$context to false after changing the attribute value, but neither of these seems to prevent the "You have unsaved changes that will be lost. Continue?" dialog from showing when closing the page.
Can you please provide some direct example of what you are trying to achieve since unfortunately it's not obvious to us what is performed on the page at the moment, what is the expected result and what is the actual result? Maybe some steps to reproduce it in the local application (like the following:
1) Add column A
2) Add attribute B
3) Connect B to A in the following manner
4) Go to the page where the column and the attribute were added
Basically all I want is to be able to set the value of an attribute in code without triggering the "You have unsaved changes that will be lost. Continue?" message when you leave the page. Is this possible?
I tried to reproduce the issue, but changing the value of the virtual attributes (like attributes created to control the visibility of the field) by itself does not cause this dialog to appear.
Please ensure that no other changes need to be saved on the page. Or provide us with additional information describing the exact steps to reproduce the issue.
Sorry, I was probably not detailed enough in my abbreviated version - the changes are actually to an attribute that is based over a real column on the entity, so not a virtual attribute. Is there any way to modify such a field in code without triggering the dialog?
Please pay attention that too many saving requests may decrease performance.
Another way is to save the necessary changed values to a virtual attribute first, and then extract all of them (set attributes values) and initiate SaveRecordRequest while closing the page (in crt. ClosePageRequest). This approach has some disadvantages:
data would be saved only on a close/back button click.
And again – you should provide some conditions in order not to store too many changes.
Additionally, starting from the 8.1.1 Creatio version, the dialog may be prevented by adding to handlers the overridden “crt.CanDiscardUnsavedDataRequest” handler:
The utility can be in setting fields from code when a create record page loads based on more complicated conditions than you can define in business rules/by other means, but not causing the user additional clicks to cancel or think that they might lose work.