Monday 16 December 2013

Access denied for the page.
Sharepoint 2013 office 365
 web site publishing pages created from a template using jsom are throwing access denied error for the users who is having read access to the pages. If the user permissions changed to full control also keep on getting the error.

Workaround: added read permission for the "everyone" to the style library the where my custom .css and image files are stored.



Thursday 12 December 2013

Get all Sharepoint site collection groups and Delete them using custom ui.


<script type="text/javascript" src="/SiteAssets/Tabs/jquery.min.js"></script>

<style type="text/css" rel="stylesheet">
a:visited{ color: gray }
delete:visited{ color: gray }
#delete{
color:red;
}
</style>

<script type="text/javascript" language="javascript">
var webs;
function loadWebs() {
   var clientContext = SP.ClientContext.get_current();
   this.webs = clientContext.get_site().get_rootWeb().get_webs();
   clientContext.load(this.webs);
   clientContext.executeQueryAsync(Function.createDelegate(this, this.onWebsLoaded), Function.createDelegate(this, this.onQueryFailed));
}

function onQueryFailed(sender, args) {
   alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
var grpdescription2 = "Description.";
function onWebsLoaded(sender, args) {
   for (var i = 0; i < this.webs.get_count(); i++) {
   var sitetitle =  this.webs.itemAt(i).get_title();
   var url = this.webs.itemAt(i).get_serverRelativeUrl();
 
   var itemid = replacespecialitems(url);
     jQuery("#data").append(" <li id='"+itemid+"'><table><tr><td class='ms-vb'><a href='/_layouts/Deletesite.aspx'>" +sitetitle +"</a> &nbsp;&nbsp;&nbsp;</td><td>&nbsp;"+url +"</td><td>&nbsp;&nbsp;<a id='noSub &quot;"+itemid+"&quot;' href='javascript:;' onclick='javascript:DeleteSubWeb( &quot;"+url+"&quot; )' >&nbsp;&nbsp; Delete Web sites&nbsp;&nbsp; </a> </td></tr></table></li>");
 
   }  
}

function replacespecialitems( url){

// to escape special charecters. wright ur own
url = url.replace("/","_");
url = url.replace("/","_");
url = url.replace("/","_");
url = url.replace("/","_");
url = url.replace("/","_");
url = url.replace("/","_");
url = url.replace("/","_");
url = url.replace(" ","_");
url = url.replace(" ","_");
url = url.replace(" ","_");
url = url.replace(" ","_");
return url;
}


//var subwebs;
var selectedweb ="",currentweburl="";
function GetallWebs( relurl){
currentweburl = relurl;
selectedweb = replacespecialitems(relurl);
 //var CurrentclientContext = SP.ClientContext.get_current(relurl);
  var CurrentclientContext =  new SP.ClientContext(relurl);
 this.subwebs =  CurrentclientContext.get_web().get_webs();

 CurrentclientContext.load(this.subwebs);
 CurrentclientContext.executeQueryAsync(Function.createDelegate(this, this.onSubWebsLoaded), Function.createDelegate(this, this.onQueryFailed));
}

function onSubWebsLoaded(){
var count = this.subwebs.get_count();
if(count > 0){
 jQuery( "#"+selectedweb).append("<ul id='"+selectedweb+"sub'></ul>>");
 for (var i = 0; i < this.subwebs.get_count(); i++){
 var subtitle =  this.subwebs.itemAt(i).get_title();
 var subsiteurl =  this.subwebs.itemAt(i).get_url();

 jQuery( "#"+selectedweb+"sub").append("<li><a href='/_layouts/Deletesite.aspx'>" +subtitle +"</a>  <a>"+subsiteurl +"</a>&nbsp;&nbsp; &nbsp;&nbsp;<span><a id='delete' href='javascript:;' onclick='javascript:DeleteSubWeb(&quot;"+subsiteurl+"&quot; )'> Delete Web </a></span></li>");
}
}
else{
currentweburl
 jQuery("#noSub"+selectedweb).append("<a onclick='javascript:DeleteSubWeb(&quot;"+currentweburl+"&quot; )'> Delete this web </a>");
}
currentweburl="";
selectedweb="";
}

function DeleteSubWeb(loc){
var clientContext = new SP.ClientContext(loc);
var oweb = clientContext.get_web();
oweb.deleteObject();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onSubWebDeleted), Function.createDelegate(this, this.onQueryFailed));
}
function onSubWebDeleted(){
console.log("Web deleted successfully.");
}

ExecuteOrDelayUntilScriptLoaded(loadWebs, "sp.js");

</script>
<div>
<ul id="data">
</ul>
</div>

Monday 9 December 2013

Sharepoint  urls

Here's the URL: http://<your site collection URL>/_catalogs/users/simple.aspx

list of webparts
 /_catalogs/wp/Forms/AllItems.aspx


User groups 
_layouts/groups.aspx

 Sitemanager page to manage pagelayouts
_layouts/sitemanager.aspx

Delete current web 
_layouts/Deleteweb.aspx


save current site as template
_layouts/savetmpl.aspx


to show site contents
_layouts/viewlsts.aspx

to see webparts and contents in side a pge

/pages/pagename.aspx?contents=1

to edit the page using url

/pages/pagename.aspx?displaymode=design

settings page

_layouts/settings.aspx



user profiles list(should be admin)

/_catalogs/users/simple.aspx



Get the version of the SharePoint server (Patch level): thanks to John
 /_vti_pvt/Service.cnf

Application page for registering SharePoint apps
/_layouts/15/appregnew.aspx

Save Site as a template
/_layouts/savetmpl.aspx

Sign in as a different user
/_layouts/closeConnection.aspx?loginasanotheruser=true

Enable SharePoint designer
/_layouts/SharePointDesignerSettings.aspx

Welcome Page (Default page settings)
/_layouts/AreaWelcomePage.aspx

Change Site Master Page
/_layouts/ChangeSiteMasterPage.aspx

Page Layouts and Site Templates
/_Layouts/AreaTemplateSettings.aspx

Master Pages library
/_catalogs/masterpage/Forms/AllItems.aspx

User Information List
_catalogs/users/simple.aspx

Quick Deploy List
Quick%20Deploy%20Items/AllItems.aspx
 
Open Page in Edit Mode
?ToolPaneView=2

Taxonomy Hidden List (MMS)
Lists/TaxonomyHiddenList/AllItems.aspx

User Information List:
_catalogs/users/simple.aspx

Force displaying the user profile in the site
collection:
/_layouts/userdisp.aspx?id={UserID}&Force=True

Web Part Maintenance Page 
?Contents=1

Show Page in Dialog View
?isdlg=1




in ie 11 if 
‘L_Menu_BaseUrl’ is undefined
‘L_Menu_LCID’ is undefined

use on top of the script 
if(typeof _spPageContextInfo !== "undefined" && _spPageContextInfo.webUIVersion === 15){
 var L_Menu_BaseUrl = L_Menu_BaseUrl || _spPageContextInfo.webServerRelativeUrl !== "/" ? _spPageContextInfo.webServerRelativeUrl : "";
 var L_Menu_LCID = L_Menu_LCID || _spPageContextInfo.currentLanguage.toString();
}
Important Note:
In SPServices Data will return from the default view of the list or library if your are not providing any view.

ECB Menu in gridview

http://code.msdn.microsoft.com/office/Ejemplos-sobre-cmo-usar-el-69cd5f16

window.onbeforeunload = function(){
console.log(window.location.toString());
            return 'Are you sure you want to leave?';
        };


Sharepoint 2013 title column navigation to custom page.



<script type="text/javascript">
$(function() {
  // Change all display form links to edit form links
  $
('.ms-vb a[href*="listform.aspx"]').each(function(){
      
var link = $(this).attr('href');
      link 
= link.replace("PageType=4", "PageType=6");
      $
(this).attr('href', link);  // use your custom url here
  });
});
</script>

sharepoint 2013 application page while using javascript client object model added script link tags.

when used onDeman=true my code started working.

 <SharePoint:ScriptLink ID="ScriptLink1" language="javascript"  OnDemand="true" Name="SP.js" defer="true" runat="server" Localizable="false"/>
    <SharePoint:ScriptLink ID="ScriptLink2" language="javascript" name="SP.Debug.js" defer="true" runat="server" Localizable="false"/>
    <SharePoint:ScriptLink ID="ScriptLink3" language="javascript"  OnDemand="true" Name="SP.Runtime.Debug.js" defer="true" runat="server" Localizable="false"/>
    <SharePoint:ScriptLink ID="ScriptLink4" language="javascript"  OnDemand="true" Name="SP.core.js" defer="true" runat="server" Localizable="false"/>