Wednesday, December 14, 2016

Hide New and Edit button from Ribbon in SharePoint 2013

<style type="text/css">
#Ribbon\.ListItem\.Manage\.EditProperties-Large
{
   display:none;
}

#Ribbon\.ListItem\.New\.NewListItem-Large
{
  display:none !important;
}


</style>

Monday, September 19, 2016

IISRESET on all Server in single shot


Again one of be powerful command by Powershell to reset IIS in all servers of a Farm in single shot. No need to open the server one-by-one.

$spserver = get-spserver | where {$_.Role -ne "Invalid"}
foreach ($server in $spserver)
{    write-host "Performing IIS Reset on Server:"$server.name 
     iisreset $server.Name

$.Role values are:-

Invalid
Specifies that the server does not have a registered role in the configuration database. This value is typically used to represent servers that are outside of the SharePoint farm.
WebFrontEnd
Specifies that the server is a front-end Web server within the SharePoint Foundation deployment, and that the server is optimized for low request latency.
Application
Specifies that the server is for back end jobs and is optimized for high throughput.
SingleServer
Obsolete. Specifies that the server is the only server in the SharePoint Foundation deployment.Do not use in SharePoint 2016 and later. Use SingleServerFarm instead.
SingleServerFarm
Available in SharePoint 2016 and later. Specifies that the server is the only server in the SharePoint Foundation deployment.
DistributedCache
Available in SharePoint 2016 and later. Specifies that the server hosts a distributed cache and optionally routes web requests.
Search
Available in SharePoint 2016 and later. Specifies that the server hosts Search services.
Custom
Available in SharePoint 2016 and later. Specifies that the server does not participate in the MinRole experience, in which services are automatically deployed to servers added to the farm based on their role. The SharePoint farm administrator must manually manage which service instances are provisioned on the server.


Wednesday, August 24, 2016

Power shell to delete WebApplication

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
 
}
cls
Remove-SPWebApplication http://SiteCollectionURL/ -Confirm -DeleteIISSite -RemoveContentDatabases

Tuesday, July 26, 2016

Nintex Form 2013 Installation Guide

Steps:
·         The installation process for Nintex Workflow and Nintex Forms requires antivirus software
to be disabled. (In all the Servers)
·         Ensure that Windows PowerShell scripts can be run by the installers
·         Install using SharePoint farm Account
·         The Nintex Forms installer must be run on a front end server.
·         Upload Evaluation License onto CA
·         Configure DB for Nintex Forms from Central admin
·         Activate Nintex forms Feature at the required web application and Site Collection level
·         Enable the Antivirus (@Sid..Kindly ask Sebastian to the needful)

·         Test the feature in the Sample Site

Custom SharePoint list form javascript file

<style type="text/css">
  .ms-formtable
  {display:none;}
</style>
<script src="../../Style Library/js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script src="../../Style Library/js/spjs-utility.js" type="text/javascript"> </script>
<script src="../../Style Library/js/jquery.SPServices-0.7.2.min.js" type="text/javascript"></script>

<script type="text/javascript">
var fldTranslationdictionary=[];
    $(document).ready(function() {

//loop through all the spans in the custom layout      
        $("span").each(function()
        {
            //get the display name from the custom layout
            displayName = $(this).attr("data-displayName");
            elem = $(this);
            //find the corresponding field from the default form and move it
            //into the custom layout
            $("table.ms-formtable td").each(function(){
                if (this.innerHTML.indexOf('FieldInternalName="'+displayName+'"') != -1){
                    $(this).contents().appendTo(elem);
                }
            });
        });




SP.SOD.executeFunc('sp.js', 'SP.ClientContext', retrieveListItems);
    });//ready() ends

function retrieveListItems()
{
 var listname = "TranslateConfig";
 var ctx = SP.ClientContext.get_current();
 this.web = ctx.get_web();
 ctx.load(this.web);
 this.list = this.web.get_lists().getByTitle(listname);
 var camlQuery = new SP.CamlQuery();
 this.collListItem = this.list.getItems(camlQuery);
 ctx.load(collListItem);
 ctx.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.getListInfoFail));
}

function onQuerySucceeded(sender, args)
{

var listItemEnumerator = collListItem.getEnumerator();
var dict = {};
var lcid = SP.Res.lcid;
while (listItemEnumerator.moveNext())
{
var oListItem = listItemEnumerator.get_current();
var Key=oListItem.get_item('Title')
//console.log("Key="+ Key);
if(lcid==1031)
{

var FieldName=oListItem.get_item('Field_x002d_DE');

//$('div.Cell h3.ms-standardheader :contains('+Key+')').text(FieldName);
//$('div.Cell h3.ms-standardheader :contains('+Key+')')[0].innerHTML=FieldName;
$("#"+Key).text(FieldName);
fldTranslationdictionary[Key]=FieldName;

}

else
{
var FieldName=oListItem.get_item('Field_x002d_EN');
//console.log("Key="+ Key +"," + FieldName);
//$('div.Cell h3.ms-standardheader :contains('+Key+')').text(FieldName);
//$('div.Cell h3.ms-standardheader :contains('+Key+')')[0].innerHTML=FieldName;
$("#"+Key).text(FieldName);
fldTranslationdictionary[Key]=FieldName;

}



}


}

function onQueryFailed(sender, args)
{
alert('Request failed for retrieveListItems(). ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>

Custom SharePoint list form (HTML)

<style type="text/css">
 .ms-long
{
width:150px
}
 .ms-rtefield
{
max-height:50px;
max-width:384px;
overflow:scroll;
}
 .Table
    {
        display: table;
border-spacing:2px;


    }
    .Title
    {
        display: table-caption;
        text-align: center;
        font-weight: bold;
        font-size: larger;
    }
    .Heading
    {
        display: table-row;
        font-weight: bold;
        text-align: center;
    }
    .Row
    {
        display: table-row;

    }
    .Cell
    {
        display: table-cell;
        border: none;
        border-width: thin;
padding-top:10px;
        padding-left: 10px;
        padding-right: 10px;
width:120px;
    }
 
    div h1{
    text-align: Center;
    margin-top: -10px;
    height: 20px;
    line-height: 20px;
    font-size: 15px;
    font-weight: bold;

}

div h1 span{
    background-color: white;
}
#load{
    width:100%;
    height:100%;
    position:fixed;
    z-index:9999;
    background:url("https://qklportal.kl.int/app/Analage/Style%20Library/Images/loading.gif") no-repeat fixed Center;
}

.labelStyle
{
width:7em;
word-wrap:break-word;
/*border: 1px solid #000000;*/
}

.sp-peoplepicker-topLevel
{

width:210px !important;
}
</style>


<div id="page" style="display:none">
  <div style="border: thin solid black;padding-bottom: 5px; margin-top: 20px;background-color:#E8E8E8">

<div class="Row">

<div class="Cell">
<H3 class="ms-standardheader">
<nobr>Title<span class="ms-formvalidation"> *</span>
</nobr>
</H3>
</div>

<div class="Cell">
<span data-displayName="Title"></span>
</div>

<div class="Cell">

<H3 class="ms-standardheader">
<div id="WorkflowStage" class="labelStyle">WorkflowStage</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="WorkflowStage"></span>
</div>




</div>
<div class="Row">

<div class="Cell">
<H3 class="ms-standardheader">
<div id="BusinessUnit" class="labelStyle">BusinessUnit</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="BusinessUnit"></span>
</div>


<div class="Cell">
<H3 class="ms-standardheader">
<div id="KLlegalEntity" class="labelStyle">KLlegalEntity</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="KLlegalEntity"></span>
</div>
</div>


<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="DocumentOwner" class="labelStyle">DocumentOwner</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="DocumentOwner"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="JobHolder" class="labelStyle">JobHolder</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="JobHolder"></span>
</div>


</div>

<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="DocumentIsValidUntil" class="labelStyle">DocumentIsValidUntil</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="DocumentIsValidUntil"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="ScrapLocation" class="labelStyle">ScrapLocation</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="ScrapLocation"></span>
</div>


</div>

<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="PassingComment" class="labelStyle">PassingComment</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="PassingComment"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="DocumentCreator" class="labelStyle">DocumentCreator</div>
</H3>

</div>

<div class="Cell">
<span data-displayName="DocumentCreator"></span>
</div>

</div>
<div style="display:none;">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="CurrentApprover" class="labelStyle">CurrentApprover</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="CurrentApprover"></span>
</div>
</div>





</div>
<!-- Scrapping Request -->
<div style="border: thin solid black; width: 100%; padding-bottom: 5px; margin-top: 20px;">
<h1>
<span>Scrapping Request</span>
</h1>

<div class="Row">


<div class="Cell">
<H3 class="ms-standardheader">
<div id="Plant" class="labelStyle">Plant</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="Plant"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="Branch" class="labelStyle">Branch</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="Branch"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="Number" class="labelStyle">Number</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="Number"></span>
</div>
</div>
<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="Requestor" class="labelStyle">Requestor</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="Requestor"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="GestelltDorf" class="labelStyle">GestelltDorf</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="GestelltDorf"></span>
</div>
</div>
<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="ProductResponsible" class="labelStyle">ProductResponsible</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="ProductResponsible"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="Disponant" class="labelStyle">Disponant</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="Disponant"></span>
</div>
</div>

<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="QM" class="labelStyle">QM</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="QM"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="SegmentLeader" class="labelStyle">SegmentLeader</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="SegmentLeader"></span>
</div>
</div>


<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="MaterialNumber" class="labelStyle">MaterialNumber</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="MaterialNumber"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="Designation" class="labelStyle">Designation</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="Designation"></span>
</div>
<div class="Cell">
<H3 class="ms-standardheader">
<div id="MaterialNumberOld" class="labelStyle">MaterialNumberOld</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="MaterialNumberOld"></span>
</div>
</div>

  <div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="MatArt" class="labelStyle">MatArt</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="MatArt"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="Vorgang" class="labelStyle">Vorgang</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="Vorgang"></span>
</div>

</div>
<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="OrderNumber" class="labelStyle">OrderNumber</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="OrderNumber"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="CompletedByAG" class="labelStyle">CompletedByAG</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="CompletedByAG"></span>
</div>
<div class="Cell">
<H3 class="ms-standardheader">
<div id="ReklaNumber" class="labelStyle">ReklaNumber</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="ReklaNumber"></span>
</div>
</div>
  <div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="TargetStuckNumber" class="labelStyle">TargetStuckNumber</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="TargetStuckNumber"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="PushStuckNumber" class="labelStyle">PushStuckNumber</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="PushStuckNumber"></span>
</div>
<div class="Cell">
<H3 class="ms-standardheader">
<div id="MiscellaneousGoodStuccoNumber" class="labelStyle">MiscellaneousGoodStuccoNumber</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="MiscellaneousGoodStuccoNumber"></span>
</div>
</div>

<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="ValueInEUR" class="labelStyle">ValueInEUR</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="ValueInEUR"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="MatCommittee" class="labelStyle">MatCommittee</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="MatCommittee"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="TotalCommittee" class="labelStyle">TotalCommittee</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="TotalCommittee"></span>
</div>
</div>

<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="Fault" class="labelStyle">Fault</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="Fault"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="ErrorCause" class="labelStyle">ErrorCause</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="ErrorCause"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="OnerousCostCenter" class="labelStyle">OnerousCostCenter</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="OnerousCostCenter"></span>
</div>


</div>

<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="ScrapAttachments" class="labelStyle">ScrapAttachments</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="ScrapAttachments"></span>
</div>
                <div class="Cell">
<H3 class="ms-standardheader">
<div id="ProfitCenterContract" class="labelStyle">ProfitCenterContract</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="ProfitCenterContract"></span>
</div>
</div>

<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="Reason" class="labelStyle">Reason</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="Reason"></span>
</div>
</div>


<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="Mabname" class="labelStyle">Mabname</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="Mabname"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="ProducedByDispo" class="labelStyle">ProducedByDispo</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="ProducedByDispo"></span>
</div>




</div>

  <div class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="RecessedLineApproved" class="labelStyle">RecessedLineApproved</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="RecessedLineApproved"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="GenehmigtGough" class="labelStyle">GenehmigtGough</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="GenehmigtGough"></span>
</div>
</div>


   </div> <!-- table ends -->

<div style="border: thin solid black; width: 100%; padding-bottom: 5px; margin-top: 20px;">
<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader" style="width:10em;">
<div id="RemarksAboutCause">RemarksAboutCause</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="RemarksAboutCause"></span>
</div>


<div class="Cell">
<H3 class="ms-standardheader" style="width:10em;">
<div id="InfluenceOnAppointmentRejection">InfluenceOnAppointmentRejection</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="InfluenceOnAppointmentRejection"></span>
</div>
</div>
<div class="Row">
<div class="Cell">
<H3 class="ms-standardheader" style="width:10em;">
<div id="BookedInSAPAndScrappedAt">BookedInSAPAndScrappedAt</div>
</H3>
</div>
<div class="Cell">
<span data-displayName="BookedInSAPAndScrappedAt"></span>
</div>
</div>
</div><!--  Table ends-->
<div id="AttachmentsDiv" style="border:thin black solid;width:100%;margin-top:20px;padding-bottom:5px"><h1><span>Attachments</span></h1>
 <div class="Table">
<div class="Row">
<div class="Cell">
<span data-displayName="Attachments"></span>

</div>

</div>


 </div>
</div>
<div style="margin-top:30px;"> </div>


<div id="KLWorkflowHistory">

 <h1><span>Approval History</span></h1>
 <div id="CustomWorkflowHistorySection" class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="CustomWorkflowHistory" class="labelStyle">CustomWorkflowHistory</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="CustomWorkflowHistory"></span>
</div>
 </div>
</div><!--End of KLWorkflowHistory-->
<!-- Approver Section -->
<div id="ApproverSectionBorder" style="border: thin solid black; width: 100%; padding-bottom: 5px; margin-top: 30px;">

<h1>
<span>Approver Section</span>
</h1>

 <div id="ApproverSection" class="Row">
<div class="Cell">
<H3 class="ms-standardheader">
<div id="ApproverStatus" class="labelStyle">ApproverStatus</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="ApproverStatus"></span>
</div>

<div class="Cell">
<H3 class="ms-standardheader">
<div id="CommentsByApprover" class="labelStyle">CommentsByApprover</div>
</H3>
</div>

<div class="Cell">
<span data-displayName="CommentsByApprover"></span>
</div>
</div><!--End of ApproverSection-->
    </div><!--End of ApproverSectionBorder-->
</div> <!-- page ends -->





<head><title></title></head>

JavaScript link over here.

Monday, April 4, 2016

Merge Log files from all Servers in SharePoint

I found this very useful.

SharePoint many times do not display precise error message and end up with below annoying error with correlation ID. Below PS command will merge SP log files from ALL servers in farm and gives the result in *.txt file.

Merge-SPLogFile -Path C:\log.txt -Correlation 29b5c483-c48b-4ef2-b4b3-f5e29f635d31



Wednesday, March 30, 2016

Cloud Caution

Hide SharePoint List form field(s) using Powershell

clear
Add-PSSnapin Microsoft.SharePoint.PowerShell

$url = "https://sitename/";
$list = "Employee Information";#Display Name
$fieldname = "Salary Info";#Display Name

#Setting up context
$contextSite = New-Object Microsoft.SharePoint.SPSite($url);
$contextWeb = $contextSite.OpenWeb();

$list = $contextWeb.Lists.TryGetList($list);
$field = $list.Fields[$fieldname];

# Controls Field in Edit Form. 0 means hide. 1 means show.
#$field.ShowInEditForm = 1;
# Controls Field in New Form
#$field.ShowInNewForm = 0;
# Controls Field in New Form
$field.ShowInDisplayForm = 0;
# Hides fields from list settings
#$field.ShowInListSettings = 1;
# Hides fields from version history
#$field.ShowInVersionHistory = 1;
# Hides fields form selection in views
$field.ShowInViewForms = 0;
# Don't forget to update this field
$field.Update();
# And finally dispose everything.
$contextWeb.Dispose();
$contextSite.Dispose();

Thursday, January 21, 2016

Get people picker value in jQuery using SPServices.

/ Get people picker value
var assigned = $().SPServices.SPFindPeoplePicker({ 
    peoplePickerDisplayName: "Assigned To",
    checkNames: true
});
OR
//Set Logged User in given people picker field ID
  function setPeoplePickerLoginName(id)
  {
   
   var PickerDiv = $('[id$="ClientPeoplePicker"][id^="' + id + '"]');
   var PickerEditor = PickerDiv.find('[title="' + id + '"]');
   var PickerInstance = SPClientPeoplePicker.SPClientPeoplePickerDict[PickerDiv[0].id];
   //You need to user SPServices library to get logged user.      
   var vUserName =$().SPServices.SPGetCurrentUser({fieldName: "Title",debug: false});
   PickerEditor.val(vUserName);
   PickerInstance.AddUnresolvedUserFromEditor(true);//V.Important line
  }
  
  
  //Return login name of given people picker.
  function getPeoplePickerLoginName(id)
  { var PickerDiv = $('[id$="ClientPeoplePicker"][id^="' + id + '"]');
   var PickerInstance = SPClientPeoplePicker.SPClientPeoplePickerDict[PickerDiv[0].id];
   if(PickerInstance)
   { return PickerInstance.GetAllUserInfo()[0].Key;// i:0#.w|domain\userName
   }
   else {return "";}
  }