Wednesday, February 3, 2016

Remove Duplicate Registration of Event Receiver- Powershell

# List all the Events registered
$weburl = "http://SharepointWeb"
$spweb = Get-SPWeb $weburl
$spList = $spWeb.Lists["ListName"]
$spList.EventReceivers | Select Name, Assembly, Type

# Remove the Event Registration at index 0
$spList.EventReceivers[0].delete()

Tuesday, February 2, 2016

.WSP using Powershell Commands

Add-SPSolution -LiteralPath C:\Temp\SendEmailwithAttachment.wsp
Install-SPSolution -identity "SendEmailwithAttachment.wsp" -GACDeployment
Uninstall-SPSolution -identity "SendEmailwithAttachment.wsp"
Remove-SPSolution -identity "SendEmailwithAttachment.wsp"

Hide/Show fields in NewForm, EditForm and DispForm.aspx in SharePoint 2010 using JQuery

Custom SharePoint list has Field "Status" with the options
1) Deferred
2) Completed
3) Waiting on response from

and another field is "Waiting on response from" is single line of text



NewForm.aspx :

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" type="text/javascript">
  </script><script type="text/javascript">
$(document).ready(function() {

var loadtext=$("select[title$='Status'] :selected").text();
if(loadtext=='Deferred')
{
$("td.ms-formlabel:contains('Waiting on response from')").parent().hide();
//$("input[title$='Waiting on response from']").attr('disabled', true);
}

$("select[title$='Status']").change(function()
{
var text = $("select[title$='Status'] :selected").text();

if(text!='Waiting on response from')
{

//$("input[title$='Waiting on response from']").attr('disabled', true);
$("td.ms-formlabel:contains('Waiting on response from')").parent().hide();
}
else
{

$("td.ms-formlabel:contains('Waiting on response from')").parent().show();
}
});
}); </script>]

EditForm.aspx:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" type="text/javascript">
  </script><script type="text/javascript">

$(document).ready(function() {

var loadtext=$("select[title$='Status'] :selected").text();
if(loadtext!='Waiting on response from')
{
$("td.ms-formlabel:contains('Waiting on response from')").parent().hide();
}
else
{
$("td.ms-formlabel:contains('Waiting on response from')").parent().show();

}

$("select[title$='Status']").change(function()
{
var text = $("select[title$='Status'] :selected").text();

if(text!='Waiting on response from')
{


$("td.ms-formlabel:contains('Waiting on response from')").parent().hide();
}
else
{

$("td.ms-formlabel:contains('Waiting on response from')").parent().show();
}
});

}); </script>

-------------------------------------------------------------------------------

DispForm.aspx:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" type="text/javascript">

  </script><script type="text/javascript">

$(document).ready(function() {

var text = $('h3:contains("Status")').closest('td').next('td').text();
alert(text.trim());
if(text.trim()!='Waiting on response from')
{
alert(1);
$("td.ms-formlabel:contains('Waiting on response from')").parent().hide();
}
else
{
alert(2);
$("td.ms-formlabel:contains('Waiting on response from')").parent().show();
}



}); </script>