Hiding new item, edit, view selector from List View Web Part in SharePoint 2013


We had a requirement to hide the new item button, edit button etc. from a List View Web Part.

 

The way we achieved it was using a Content Editor Web Part and pointing it to Jscript File with the following CSS,

By finding the following id(s) and setting display as none.

List View with hidden controls.

Cannot retrieve the URL specified in the Content Link property. For more assistance, contact your site administrator error in SharePoint.


We were getting this error in one of our pages in SharePoint.

Just verify the Content Link it might not be pointing to correct url in the Content Editor Web Part.

Hope it helps..

Check if a user is a SharePoint Administrator in JavaScript – SharePoint 2013.


Hi,

Had a requirement to check if user is a SharePoint Admin or not and accordingly hide few elements in the page. We used the below code in our custom master page

Sample Code


var currentUser;

function IsUserAdmin() {
clientContext = SP.ClientContext.get_current();
spWeb = clientContext.get_web();
currentUser = spWeb.get_currentUser();
clientContext.load(currentUser);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded(sender, args) {

var isUserAdmin = currentUser.get_isSiteAdmin();
if (isUserAdmin) {

alert('Current User is Administrator');

} else {

alert('Current User is not an Administrator');
}
}

function onQueryFailed(sender, args) {

alert('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());
}

ExecuteOrDelayUntilScriptLoaded(GetCount, "sp.js");

Hope it helps ..

Sample PowerShell script to create web application and a site collection in SharePoint 2013


Just sharing a sample script that we are using to create a web application and a site collection of type publishing in it.

 

# SharePoint cmdlets
Add-PsSnapin Microsoft.SharePoint.PowerShell</pre>
# Set variables
$WebAppName = "MyAppPool"
$WebAppHostHeader = "servername"
$WebAppPort = "portnumber"
$url = "http://servername"
$WebAppAppPool = "MyAppPool"
# This User has to be a Sharepoint Manager Account
$WebAppAppPoolAccount = "domain\username"
$AuthenticationMethod = "NTLM"
$ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos

# Create a new Sharepoint WebApplication
New-SPWebApplication -Name $WebAppName -Port $WebAppPort -HostHeader $WebAppHostHeader -URL $url -ApplicationPool $WebAppAppPool -ApplicationPoolAccount (Get-SPManagedAccount $WebAppAppPoolAccount) -AuthenticationMethod $AuthenticationMethod -AuthenticationProvider $ap

# Set variables
$SiteCollectionName = "MySiteCollection"
$SiteCollectionURL = "http://servername:portnumber/"
$SiteCollectionTemplate = "BDR#0"
$SiteCollectionLanguage = 1033
$SiteCollectionOwner = "LSS\lssspadmin"

# Create a new Sharepoint Site Collection
New-SPSite -URL $SiteCollectionURL -OwnerAlias $SiteCollectionOwner -Language $SiteCollectionLanguage -Template $SiteCollectionTemplate -Name $SiteCollectionName

Hope it helps ..

Use TryGetList to check if a list exist in SharePoint (SharePoint Object Model)


Hi,

We were getting the following error that “list doesn’t exist in the site” because the user was not having read permission on that list.

The code we were using was

SPList myList= spWeb.Lists[“mylist”];

A better approach would be

SPList myList = spWeb.Lists.TryGetList(“myList”);

If(myList != null )

// …

Bye ..

Fixed – Error creating web application in SharePoint 2013.


Hi,

We were facing issues while creating a new web application through central administration. The user was the farm administrator.

The way we got it fixed was by increasing the set the values for the properties in the Central Admin Sites’ App Pool

Followed by an IISRESET

Hope it helps ..