Search This Blog

Monday, June 29, 2015

How to hide a Yes/No column in NewForm.aspx and EditForm.aspx in sharepoint 2013

We can't hide the Yes/No field using OOB in sharepoint. Better we go for script editor to hide the particular column. Apply the following steps.

Add in the Content Editor Web Part located under the Media and Content category.

Paste the following code:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
    $('nobr:contains("TestColumn")').closest('tr').hide(); 
});

</script>

you can use this for multiple columns also.


thank you.



Wednesday, June 24, 2015

Two different timer job shows the same name in job definition

This usually happens when you add two or more timer jobs in single solution. This one tested me a lot. This issue usually comes when we go for two features for two timer jobs.
Guess what here is the place we do mistake usually.

When we copy paste the code for feature receiver from one feature to another one we just copy and paste it where we don't much care about any changes in that code. because it is already working fine. Of course its working fine but still it needs a little change.

Feature 1:
      Feature Activated:
       TestJob1 listLoggerJob = new TestJob1 (List_JOB_NAME, site.WebApplication);

Feature 2:
    Feature Activated:
      TestJob2 listLoggerJob = new TestJob2 (List_JOB_NAME, site.WebApplication);

So guys please don't forget to change the class name where you create your timer job. Don't just copy and paste, just review it at-least once. It took me some time to find this silly mistake.


thank you


Get Row ID of inserted data in SharePoint list

SPList spList = spWeb.Lists["Announcements"];
SPListItem spListItem = spList.Items.Add();
spListItem["Title"] = "Hello world";

spListItem.Update();
int RowID = spListItem.ID;  //This is the ID of the new item.

Tuesday, June 23, 2015

How to enable custom errors in Share point error

In share point while getting error we may see the correlation ID. But that is not really understandable i guess.
But we do have an option to enable custom error message which is understandable by anyone.

Here are the steps to enable that settings:

1. 15/Layouts folder we have a web.config file. In that file find Custom Errors and change its mode          as Off
    Ex: customErrors mode="Off"

2. Open your webapplication's web.config file.
     a) Find CallStack and change it's value as true
          Ex: CallStack="true"
     b) Find find Custom Errors and change its mode as Off
          Ex: customErrors mode="Off"
     c) Find debug and change its mode as true
          Ex: debug="true"

Once you finished these steps, hereafter you will get clean error message and you can solve it in your way..


thank you

Saturday, June 20, 2015

page.response.redirect is not working

In sharepoint some times we cant use the Response.Redirect.

So we can use SPUtility.Redirect to redirect to other pages.

SPUtility.Redirect("/SitePages/CustomAccessDenied.aspx", SPRedirectFlags.Static / SPRedirectFlags.Default / SPRedirectFlags.Trusted, HttpContext.Current);

Like this we can redirect to other pages in sharepoint

Friday, June 19, 2015

How to add Custom validation for Newform.aspx and Editform.aspx in Sharepoint 2013

I am using PreSaveAction() JavaScript function to check whether start day is lower than End day or not. If it is lower than greater than end day then it will show an alert message;

Add in the Content Editor Web Part located under the Media and Content category.

Paste the following code:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript">
 var j = jQuery.noConflict(); 
 function PreSaveAction() { 
 var startDay= j(":input[title='Start_Day']").val(); 
var endDay= j(":input[title='End_Day']").val(); 
if(startDay=='')
{
alert("Please enter start day");
return false;
}
else if(endDay=='')
{
alert("Please enter end day");
return false;
}
else if(endDay < startDay)
{       
   alert("End day should be greater than start day");          
   return false;
}
else{
   return true;
    }
}

</script>

thank you..

How to Disable Quick Edit in SharePoint 2013 Lists


By default SharePoint 2013 lists allow you to quickly edit items by clicking "edit" from the view without opening it.

Now, if you want to disable this function follow these steps:
  1. Go to the list settings> Advanced settings page
  2. Scroll down and Under quick edit options just choose "No" and then click OK.
     3. Now you can see that quick edit is disabled from the list.

Restricting Custom People Picker to only one Sharepoint group programatically

Refer the following script files in your page,     <!-- For People Picker -->     <script type="text/javascript" src...