Interview Questions administrator

Best SharePoint administrator Interview Questions and Answers with topic wise:


Recycle Bin | MMS | ManagedVsCrawledProperties |
Showing posts with label datetimecontrol. Show all posts
Showing posts with label datetimecontrol. Show all posts

Thursday, November 20, 2014

Setup [Today] as default to the sharepoint date time control through browser


Step1:
Create a new date time field and set the calculated value as “Today”. That’s it.
Create a new item into the list. There you can see set the Today’s date as default to the date time field.

Step2
Creata new item into the list and there you will see the set the Today's date as default to the sharepoint date time field.[PFB the image]

Sunday, September 21, 2014

Create sharepoint datetime control using powershell script

Visit my previous post for to create a list through powershell script
Create list using powershell script
*********************************************************************************
$lncustomListName listName
$docSite = new-object Microsoft.SharePoint.SPSite($siteURL)
$docWeb = $docSite.OpenWeb()

/* To create DateTime field for allow only one user/group */
Add-SPDateTimeField -listName $lncustomListName -Name DateTimeFieldName  -DisplayName DateTimeFieldName  -DateType DateOnly -Required FALSE

/* Method to create people DateTime field */
function Add-SPDateTimeField([string]$listName, [string]$DisplayName, [string]$Name, [string]$Required, [string]$DateType)
{
   $OpenList = $docWeb.Lists[$listName]
   $fldXml = "<Field Type='DateTime' DisplayName='"+ $DisplayName +"' Format='"+ $DateType +"' Required='"+ $Required +"' Name='"+ $Name +"'/>"
   $OpenList.Fields.AddFieldAsXml($fldXml,$true,
   [Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView)
}
**********************************************************************************
Please let me know if faced any issues.

Friday, July 18, 2014

sharepoint datetimecontrol validation using JQuery

This post helps us on below mentioned validations.
  1. Required validation.
  2. Selected date time cannot be less than current date


//To get the selected date time control value

var selectedDateTimeVal = $('input[id*="dtcDateTimeCtrl"]').val();

//Required validation

if (selectedDateTimeVal == '') {
  
alert("Date Time control field value is required");

}

else
{
 var date = new Array();

 var currDate = new Date();

 // Input date format : mm/dd/yyyy

 date = selectedDateTimeVal.split('/');

 var year = date[2];

 var month = date[1];

 var date = date[0];

 var selectedDate = month + "/" + date + "/" + year;

 var tarDate = new Date(selectedDate);

 var timeDiff = tarDate.getTime() - currDate.getTime();

 var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));

 if (parseInt(diffDays) < 0) {

  alert("Selected datetime value cannot be less than current date");

  }
}