Problem with Query.saveQueryViews() on public views

LabKey Support Forum (Inactive)
Problem with Query.saveQueryViews() on public views jeckels  2014-01-06 17:46
Status: Closed
 
Hi Andy,

You should be able to use the "shared" property (a boolean) in the response from getQueryViews() to see if an existing view is public or not.

Similarly, as it sounds like you've discovered, you can control whether a saved view is public or not with the "shared" property when saving. However, looking at the code, it looks like it may handle promoting a private view to be public, but not the other way around.

As a client-side workaround, one possibility would be to call deleteView API. It's not exposed via a JavaScript wrapper in LABKEY.Query, but an example usage from the Customize View UI looks like:

        Ext.Ajax.request({
            url: LABKEY.ActionURL.buildURL("query", "deleteView", this.containerPath),
            jsonData: {schemaName: this.schemaName, queryName: this.queryName, viewName: this.viewName, complete: complete},
            method: "POST",
            scope: this,
            success: function() { window.location.reload() }
        });

Can you reply with the error you're getting when saving when both public and private versions already exist?

Thanks,
Josh