Hi I'm pretty new to SharePoint and javascript. I am trying to check if the content database is read-only, and if it is then preform a function
eg.
if (!site.WebApplication.ContentDatabases[0].IsReadOnly)
{
if (!site.ReadOnly)
{
alert("readonly");
}
}
else
{
alert("not read only");
}
I can't get this to work.Any help would be great.
-
What is happening? More details?Sam Sussman– Sam Sussman2013-01-10 13:34:37 +00:00Commented Jan 10, 2013 at 13:34
-
Well nothing is happening. I'm guessing that the if (!site.WebApplication.ContentDatabases[0].IsReadOnly) { if (!site.ReadOnly) statement isn't working as it should.Tobiasmoreilly– Tobiasmoreilly2013-01-10 13:47:54 +00:00Commented Jan 10, 2013 at 13:47
-
Try outputting other components of this, or not using IE so you can see errors. Put an alert around the ContentDatabase readonly logic to see if it outputs anything, or even the WebApplication variable. My guess is something hasn't been loaded yet.Sam Sussman– Sam Sussman2013-01-10 13:52:32 +00:00Commented Jan 10, 2013 at 13:52
-
Getting error: Uncaught ReferenceError: site is not defined (anonymous function)Tobiasmoreilly– Tobiasmoreilly2013-01-10 14:23:36 +00:00Commented Jan 10, 2013 at 14:23
-
Well then site doesn't exist! Where is the rest of your code?Sam Sussman– Sam Sussman2013-01-10 14:26:53 +00:00Commented Jan 10, 2013 at 14:26
1 Answer
Just a thought, but your JavaScript might not have permission to see the WebApplication or the ContentDatabases. Try adding alerts, something like Site.Title, Site.WebApplication.Title, Site.WebApplication.ContentDatabases.Count, etc. to see how far you can go.
As an aside, what exactly are you trying to do? I haven't seen someone trying to get to the Content Database through JavaScript before. If the current user can't see the Content Database, then they can't see the site they are currently on, either. Or are you trying to look at a site other than the one you are on??