Tuesday 23 September 2014

Sharepoint resize modal dialog window

 SP.SOD.executeOrDelayUntilScriptLoaded(resizeModalDialog, 'sp.js');
 function resizeModalDialog(){
 var dlg = typeof(SP.UI.ModalDialog.get_childDialog) == "function" ? SP.UI.ModalDialog.get_childDialog() : null;
    if (dlg != null) {
        dlg.autoSize();
}
 }



Modal dialog window

<div class="ms-dlgContent">
    <div class="ms-dlgBorder">
        <div class="ms-dlgTitle"></div>
        <div class="ms-dlgFrameContainer"></div>
    </div>
</div>
Sharepoint 2010 css refference chart

http://sharepointexperience.com/csschart/csschart.html

Thursday 4 September 2014

GET All Sub Sites and Users Info and Lists Info Using Javascript with console window
tested in sharepoint 2007 , 2010 & 2013


console.clear();
var jQueryScriptOutputted = false;
function initJQuery() {
    if (typeof(jQuery) == 'undefined') {
if (! jQueryScriptOutputted) {
jQueryScriptOutputted = true;    
var path   = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js";
var sppath = "http://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.1a/jquery.SPServices-0.7.1a.min.js";
var script   = document.createElement( 'script' );
script.src   = path;
document.getElementsByTagName( 'head' )[0].appendChild( script );
            var spservice =   document.createElement('script');
            spservice.src= sppath;
            document.getElementsByTagName( 'head' )[0].appendChild( spservice );
        }
        setTimeout("initJQuery()", 100);
}
else {
$(function() { ExecuteRequiredScript(); });
}
}
initJQuery();
var AllLists = "";
function ExecuteRequiredScript(){
GetAllSubWebs();
}
function GetAllSubWebs(){
var count = 0;
console.clear();
$().SPServices({
         operation:"GetWebCollection",//GetWebCollection,GetAllSubWebCollection
         async: false,
         completefunc: function (xData, status) {
console.log(status);                      
$(xData.responseXML).find("Web").each(function() {        
count++;

var title = $(this).attr("Title");

var url = $(this).attr("Url");  
console.log(title +"\t" +url );

if(url.indexOf("current weburl") > -1){

getOwnersgrpNAme(title,url);
getUsers(title,url);
}
});
//console.log( AllLists);
console.log(" Sub Webs count \t"+count);
}
});
}
function getCurrentUserRoleforUser(username,url) {//alert(username);
var rolename="";
var counter=0;
    $().SPServices({
        operation: "GetRoleCollectionFromUser",
userLoginName:username,
webURL:url,
        async: false,
        completefunc: function (xData, Status) {
            if( Status == "success") {

                $(xData.responseXML).find("Role").each(function () {
                   if(counter==0)
{
                    rolename=$(this).attr("Name");
counter++;
}
else
{
rolename+=";"+$(this).attr("Name");
}
                });
            }
        }
    });
return rolename;
}
function getCurrentUserRole(group,url) {
var rolename="";
var counter=0;
    $().SPServices({
        operation: "GetRoleCollectionFromGroup",
groupName:group,
webURL:url,
        async: false,
        completefunc: function (xData, Status) {
            if( Status == "success") {
                $(xData.responseXML).find("Role").each(function () {
 if(counter==0)
{
                    rolename=$(this).attr("Name");
counter++;
}
else
{
rolename+=";"+$(this).attr("Name");
}
                });
            }
        }
    });
return rolename;
}
function getUsers(title,url)
{
var perms="";
   $().SPServices({
    operation: "GetUserCollectionFromWeb",
    webURL: url,
async: false,
    completefunc: function (xData, Status) {


    $(xData.responseXML).find("User").each(function() {
     
        var liHtml = $(this).attr("Name");
perms=getCurrentUserRoleforUser($(this).attr("LoginName"),url);

        AllLists +=  title+"\t"+url+"\t"+perms+"\t"+liHtml+"\t"+"\n";
     });
console.log( AllLists);
     }
});
}


function getOwnersgrpNAme(title,url){
console.log("Getting Owners");
var siteusers="",rolename="";
 $().SPServices({
  operation: "GetGroupCollectionFromWeb",
  webURL:url,
  async: false,
  completefunc: function(xData, Status) {
   //var AllLists = "";
  $(xData.responseXML).find("Group").each(function () {
        var name = $(this).attr("Name");
  rolename=getCurrentUserRole(name,url);
        siteusers=getGroupOwners(title,url,name);  
AllLists +=  title+"\t"+url+"\t"+rolename+"\t"+name+"\t"+siteusers+"\n";
      });
     console.log( "successuser1");
  }
 });
 //return siteowner;
}
function getGroupOwners(title,url,groupName) {
    var ownerdata = "";

    // Gets users within Owners group
    $().SPServices({
    operation: "GetUserCollectionFromGroup",
    groupName: groupName,
webURL:url,
    async: false,
    completefunc: function (xData, Status) {
//alert(groupName+" "+Status);
      $(xData.responseXML).find("User").each(function () {
        var displayName = $(this).attr("Name");
        if(ownerdata ==""){
     ownerdata =displayName ;
 }
 else{
  ownerdata =ownerdata +";"+displayName ;
 }
      });
    }
   });
   return ownerdata;
}
function GetAllListsIntheSite(wburl,title,siteOwners){
$().SPServices({
        operation: "GetListCollection",
        webURL:wburl,
        async: false,
        completefunc: function( xData, Status ) {      
var AllLists = "",AllLibraries = "",UngroupedLists = "";
            $( xData.responseXML ).find("Lists > List").each(function() {
                var $node = $(this);
var ListTitle = $node.attr("Title");
var ListDefaultviewUrl = $node.attr("DefaultViewUrl");
var modified = $node.attr("Modified");
var modifiedstr=modified.substr(4,2)+"/"+modified.substr(6,2)+"/"+modified.substr(0,4)+" "+modified.substr(9,2)+":"+modified.substr(12,2);
if(ListDefaultviewUrl.indexOf("/_catalogs/")== -1){
if(ListDefaultviewUrl.indexOf("/Lists/") > 0){
var itemCount=GetItemCount(ListTitle,wburl);
AllLists +=  ListTitle+"\t , \t"+"List"+"\t , \t"+ListDefaultviewUrl+"\t , \t"+title+"\t , \t"+wburl+"\t , \t"+siteOwners+"\t , \t"+modifiedstr+"\t , \t"+ itemCount +" Items"+"\n";
}
else if(ListDefaultviewUrl.indexOf("/Forms/") > 0){
AllLibraries +=ListTitle+"\t , \t"+"Document Library"+"\t , \t"+ListDefaultviewUrl+"\t , \t"+ title+"\t , \t"+wburl+"\t , \t"+siteOwners+"\t , \t"+modifiedstr+"\n";
}
else{
UngroupedLists +=ListTitle+"\t , \t"+" "+"\t , \t"+ListDefaultviewUrl+"\t , \t"+ title+"\t , \t"+wburl+"\t , \t"+siteOwners+"\t , \t"+modifiedstr+"\n";
}
}              
            });                                              
            //console.log( AllLists);
            console.log( AllLibraries);          
            console.log( UngroupedLists);
        }
});
}
function GetItemCount(ListTitle,wburl){
var count=0;
$().SPServices({
operation: "GetListItems",
listName: ListTitle,
async: false,
webURL: wburl,
completefunc: function (xData, status) {
count=  $(xData.responseXML).SPFilterNode("rs:data").attr("ItemCount") * 1;
}
});
return count;
}

Thursday 7 August 2014

Global Navigation add class based on selected node sub node.

 $('.ms-core-listMenu-root > li > ul').find('li.dynamic >a[href^="/' + location.pathname.split("/")[1] + '"]').closest('li.dynamic-children').addClass('DefaultSelected');


Saturday 2 August 2014

Sharepoint 2013 show PDF document in flyoutmenu
http://www.wictorwilen.se/sharepoint-2013-enabling-pdf-previews-with-office-web-apps-2013-march-2013-update



Monday 7 July 2014

In IE add and select option dynamically is not working.

$(document).ready(function()
   {
   $("select[title='lookup Required Field']").prepend("<option value='' selected='selected'>-select-</option>");
setTimeout("SelectItem()", 100);
});

function SelectItem()
{
$("select[title=lookup Required Field'] option:eq(0)").attr('selected', 'selected');
}

Saturday 28 June 2014

SharePoint external List data from BDC read using c#

string txt = "Fieldvalue";

                string url = SPContext.Current.Site.Url.ToString();
                SPUserToken token = SPUserToken.SystemAccount;
                using (SPSite osite = new SPSite(url, token))
                {
                    using (SPWeb oweb = osite.OpenWeb())
                    {
                        BdcServiceApplicationProxy proxy = (Microsoft.SharePoint.BusinessData.SharedService.BdcServiceApplicationProxy)SPServiceContext.Current.GetDefaultProxy(typeof(Microsoft.SharePoint.BusinessData.SharedService.BdcServiceApplicationProxy));
                        DatabaseBackedMetadataCatalog catalog = proxy.GetDatabaseBackedMetadataCatalog();
                        IEntity ectResource = catalog.GetEntity(url, Name);
                   
                        foreach (KeyValuePair<string, IMethod> method in ectResource.GetMethods())
                        {
                            IMethodInstance methodInstance = method.Value.GetMethodInstances()[method.Key];
                     
                       
                            if (methodInstance.MethodInstanceType == MethodInstanceType.SpecificFinder)
                            {
                                Identity identity = new Identity(txt);
                                IEntityInstance entInstance = ectResource.FindSpecific(identity, ectResource.GetLobSystem().GetLobSystemInstances()[0].Value);

                                if (entInstance[Const.ITEM_NO].ToString() == txt)
                                {
                                    if (ddlBrandName.Items.Count > 0)
                                    {
                                        ddlBrandName.Items.Clear();
                                    }
                                    ddlBrandName.Items.Add(new ListItem(entInstance[Const.BRAND_DESCRIPTION].ToString()));
                                    txtSameAsDesc.Text = entInstance[Const.ITEM_DESC].ToString();
                                    txtSize.Text = entInstance[Const.PACK_SIZE].ToString();
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }

Thursday 29 May 2014

Office 365 Get User Photo using jsom error

try with src="/_layouts/15/userphoto.aspx?size=S&url="+imageurlfromuserProfile

Wednesday 21 May 2014

update multiple people column using spservices
http://spservices.codeplex.com/discussions/277482

Monday 19 May 2014

Enable debugging in sharepoint 2013 visual studio workflow



http://msdn.microsoft.com/en-us/library/office/jj163199(v=office.15).aspx#bkm_Developing

Monday 12 May 2014

Display fields from a view in gridview 

while creating grid view column check


 SPView view = curList.Views[Convert.ToString(Property2)];
  SPListItemCollection oitem = curList.GetItems(view);
                        ViewTable = oitem.GetDataTable();
 foreach (DataColumn column in ViewTable.Columns)
                        {
                            if (view.ViewFields.Exists(column.ColumnName))
                            {
                                BoundField Boundcolumn = new BoundField();

                                Boundcolumn.DataField = column.ColumnName;
                                Boundcolumn.HeaderText = column.ColumnName;
                                Boundcolumn.SortExpression = column.Caption;
                                gdv.Columns.Add(Boundcolumn);
                            }
                        }

Sunday 11 May 2014

Custom people picker control set data


  <span class="formlable">
                    <spuc:PeopleEditor ID="pplAssignedTo" runat="server"  AllowEmpty="true" MultiSelect="false" SelectionSet="User" />
                </span>


   string primaryUser = string.Empty;

                if (pplAssignedTo.ResolvedEntities.Count > 0)
                {
                    PickerEntity pickerEntity = (PickerEntity)pplAssignedTo.ResolvedEntities[0];
                    primaryUser = pickerEntity.Key;
                    SPUser user = SPContext.Current.Web.EnsureUser(primaryUser);
                    oCurrentItem[Const.QA_DOC_REVIEWER] = user.ID;
                }


Friday 9 May 2014

hide fields in sharepoint forms by name using jquery


$('tr:has(input[title=Disclaimer])').not('tr:has(tr)').hide();
$("nobr:contains('Packaging Number')").closest('tr').hide(); 


disable fields 
  jQuery("SELECT[title*='ClientName']").attr('disabled', true);


http://davidlozzi.com/2014/01/14/sharepoint-2013-script-hide-or-disable-your-fields/ 

Thursday 10 April 2014

Get last added item using rest

site/_vti_bin/listdata.svc/ListName?$select=Id&$orderby=Id%20desc&$top=1

Friday 4 April 2014


Modal popup using xslt

  <a class="clsTitle" onclick="javascript:SP.UI.ModalDialog.ShowPopupDialog('{$SafeLinkUrl}'); return false;" title="{@LinkToolTip}">
                  <xsl:if test="$ItemsHaveStreams = 'True'">





<!--code for modal popup -->
  <xsl:template name="ModalDialogPopUp" match="Row[@Style='ModalDialogPopUp']" mode="itemstyle">
        <xsl:variable name="SafeLinkUrl">
            <xsl:call-template name="OuterTemplate.GetSafeLink">
                <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="DisplayTitle">
            <xsl:call-template name="OuterTemplate.GetTitle">
                <xsl:with-param name="Title" select="@Title"/>
                <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
            </xsl:call-template>
        </xsl:variable>
        <div class="item link-item bullet">
            <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
            <a onclick="javascript:SP.UI.ModalDialog.ShowPopupDialog('{$SafeLinkUrl}'); return false;" onmouseover="javascript:this.style.cursor='hand';" title="{@LinkToolTip}">
                        <xsl:value-of select="$DisplayTitle"/>
            </a>
        </div>
    </xsl:template>
 
  <!-- End of modal popup code -->
  

Saturday 29 March 2014

CSR /JSLink

;(function(){
 var priorityFiledContext = {};  
    priorityFiledContext.Templates = {}; 
priorityFiledContext.Templates.Header = "<div id='CompanyAnnounce'>";
priorityFiledContext.Templates .Footer="</div>";
   priorityFiledContext.Templates.Item = priorityFiledTemplate; 
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(priorityFiledContext); 
})();
function priorityFiledTemplate(ctx) { 
 var oItem = ctx.CurrentItem;
 var render = "<table id='tblAnnouncement'><tr><td><h4><b>"+oItem["Title"]+"</b></h4></td></tr>";
 render += "<tr><td  style='align:left;color:red;'><span style='color:black;'>By </span>"+oItem["Author"][0].title+"</td></tr>"; 
 render += "<tr><td style='color:red;float:right;'> "+oItem["Created"]+"</td></tr>"; 
 render += "<tr><td ><p> "+oItem["Body"]+"</p></td></tr>";
render += "</table>";  
 return render;
}

Tuesday 25 March 2014


SharePoint - JavaScript current page context info

http://johnliu.net/blog/2012/2/3/sharepoint-javascript-current-page-context-info.html
html page insert iframe without border use seamless

<iframe src=" test.html" seamless ></iframe>

Thursday 20 March 2014

Sharepoint open Page   with out or With ribon control using query string.

in the query string use below attribute to show or hide ribbon control.
InitialTabId=Ribbon.WebPartPage
InitialTabId=Ribbon.Read

http://msdn.microsoft.com/en-us/library/microsoft.web.commandui.ribbon_members.aspx

Sunday 16 March 2014

One of the simplest way is to create your Watermark function for HTML Inputbox
<input
type="text"
value="Search Wiki"
name="visitors_name"
onblur="if(value=='') value = 'Search Wiki'"
onfocus="if(value=='Search Wiki') value = ''"
/>

Thursday 13 March 2014

 Add custom master page

http://pratapreddypilaka.blogspot.in/2013/03/deploying-custom-master-page-using.html

http://frederik.se/how-to-deploy-a-custom-master-page-in-sharepoint-2013-using-visual-studio/

Wednesday 12 February 2014

If there is error in regular expression remaining expressions in the page also are not validating. with out validating form is getting submitted.



Regular expression to validate whether all number of an integer should not 
be zero as 00, 000 ,0 , 0000
  ^(?=.*[1-9].*)[0-9]{1,5}$

Monday 13 January 2014

Regular expression to validate Date in mm/dd/yyyy format


ValidationExpression="^(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$"

http://www.freeformatter.com/regex-tester.html#documentation
Find out the current Site template
view page source and find.


g_wsaSiteTemplateId

Thursday 9 January 2014






Changing the Windows PowerShell Script Execution Policy:-

Get execution policy: Get-ExecutionPolicy

The Set-ExecutionPolicy cmdlet enables you to determine which Windows PowerShell scripts (if any) will be allowed to run on your computer. Windows PowerShell has four different execution policies:
  • Restricted - No scripts can be run. Windows PowerShell can be used only in interactive mode.
  • AllSigned - Only scripts signed by a trusted publisher can be run.
  • RemoteSigned - Downloaded scripts must be signed by a trusted publisher before they can be run.

  • Unrestricted - No restrictions; all Windows PowerShell scripts can be run.

Tuesday 7 January 2014

get list of worker process running using command prompt:-
c:\Windows\System32\inetsrv> appcmd list wp