
I use formContext.getControl(fieldName).addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, isDefault) to add custom view, but it's being added to list every page refresh through "Refresh" button. There is no problem when user refresh page through browser refresh.
I guess, there is used views cache while using form refresh button, that's why my custom views duplicate.
I don't know how to get list of this views for checking my custom view availability in there. I tried to make an Retrieve Call using ODATA to get the savedqueries, but there were only views that I can see in Customization settings section, and there are no views added from script.
Also, using some boolean to check whether function has been called already doesn't help because every form refresh, even through form refresh button, script is being reloaded.
Maybe there is some way to force cache clean up?