Hi.
I just wanna ask is there anyway to retract the state of the page after making a change via setting back the value to oldValue and making sure that HasUnsavedData is false so that Save and Cancel will remain hidden?
So far under crt.HandleViewModelAttributeChangeRequest, I've tried setting the value of
HasUnsavedData to false, but did not work.
Like
If you're saying that you want to change an attribute value, but not have that show as a "change" and have the page show that it has unsaved data, you can use request.preventAttributeChangeRequest = true; when you set the value and it won't trigger a change request for the change. Or did I misunderstand what you're after?
Ryan
Ryan Farley,
Yes and no. I added a logic to check some certain values before deciding if the change in DCM stage is allowed or should I retain oldValue. It is something that BR can't do since I needed to do a prompt.
Yes, I think this will work: request.preventAttributeChangeRequest = true;
Let me try.
Ryan Farley,
Are you saying you can set request.preventAttributeChangeRequest within a custom override of the handler crt.HandleViewModelAttributeChangeRequest and that will prevent Creatio from considering that the field has changed? Even if the field was changed by a user in the UI? As that would be great news if so, though I think you possibly mean the existing functionality described in this thread: https://community.creatio.com/questions/mark-pages-field-unchanged-not-dirty-code
Which is useful but sound like it doesn't quite cover the ask of Solem (if I understood it correctly).
Harvey Adcock,
I've only seen the preventAttributeChangeRequest shared by Creatio previously, I asked for further clarification on what it actually means but never got a reply. My understanding is that if you set that to true in a given request, other attributes you change within that same request will not trigger the change (and therefore won't mark as dirty). That's only an assumption on my part since it was never explained further when asked.
Hello,
For crt.HandleViewModelAttributeChangeRequest, the platform injects these runtime fields into request: attributeName, value, oldValue, preventAttributeChangeRequest, preventStateChange, preventRunBusinessRules. So Ryan approach is correct and "official" - setting request.preventAttributeChangeRequest = true and not calling next?.handle(request) stops the change from ever reaching the ViewModel, meaning HasUnsavedData never gets set - there's no need to manually restore oldValue.
Dmytro Vovchenko,
This is interesting Dmytro, so with the following setup:
- Add a crt.HandleViewModelAttributeChangeRequest handler which checks if it's a specific attribute (let's call it PDS_UsrTextField1) and if so, sets the request.preventAttributeChangeRequest to false and doesn't return next?.handle(request)
Would this be the behaviour?:
- When a user updates the value in the crt.Input field linked to PDS_UsrTextField1, there would be no change to the underlying attribute, and so no Save button would appear
- Even when the Save button was visible for some other reason, the page would not save that value back to the database
It would be really useful to know this.