Thursday, June 20, 2013

Update DateTime Field In Event Receiver

Updating DateTime Field In Event Receiver sometimes give error, if we use:
properties.AfterProperties["ApprovedTimeStamp"] = DateTime.Now.
ToString(); ;
properties.AfterProperties["ApprovedTimeStamp"] = DateTime.Now.ToShortDateString();

Above statements give error as,
Invalid date/time value. A date/time field contains invalid data. Please check thevalue and try again.


This issue is because, SharePoint date-time field accept values in predefined format.
To overcome this issue, try:
properties.AfterProperties["DueDate"] =
DateTime.Now.ToString("yyyy-MM-ddThh:mm:ssZ");

Tuesday, June 18, 2013

JavaScript to Create Media player In SharePoint 2010

Steps to Create Media player In SharePoint 2010 using JavaScript:

1. Create new page in SharePoint site

2. Get <div> on newly created page

Example: <div id=”videoHolder”></div>

3. If page is inherited from master page, find “PlaceHolderAdditionalPageHead” and insert script tag with source as “_layouts/mediaplayer.js”

Example: <script type="text/javascript" src="_layouts/mediaplayer.js"></script>

4. Have one more script tag with following content:

<script type="text/javascript" >

_spBodyOnLoadFunctionNames.push("CreateMediaPlayer");

function CreateMediaPlayer()
{
    var videoUrl = “/Videos/MyVideo.wmv”; // video URL
    insertVideo(document.getElementById("videoHolder"),videoUrl);
}
function insertVideo(videoHolder,videoURL)
{
    mediaPlayer.createMediaPlayer(videoHolder,videoHolder.id, '400px','266px',
    {
         displayMode:'Inline',

         mediaTitle:’Help Video',
         mediaSource:videoURL,
         previewImageSource:'',
         autoPlay:true,
         loop:true,
         mediaFileExtensions:'wmv;wma;avi;mpg;mp3;',
         silverlightMediaExtensions:'wmv;wma;mp3;'
    });
}
</script>


5. Make sure the 
value of variable "videoUrl" is set correctly.

5. Save the page. That’s it!!!

6. Open the page and see the magic.

Thursday, June 13, 2013

SharePoint Modal Window Using JavaScript

Two ways to open SharePoint Modal Window using JavaScript:

1. Using the DialogOptions class.
var options = SP.UI.$create_DialogOptions();

options.title = "My Dialog Title";
options.width = 400;
options.height = 600;
options.url = "/_layouts/DialogPage.aspx";

SP.UI.ModalDialog.showModalDialog(options);

2. Using a generic object.
var options = {
    title: "My Dialog Title",
    width: 400,
    height: 600,
    url: "/_layouts/DialogPage.aspx" };

SP.UI.ModalDialog.showModalDialog(options);

Ref.: http://msdn.microsoft.com/en-us/library/ff410058(v=office.14).aspx

Wednesday, June 5, 2013

Hide Left Panel/Quick Launch From SharePoint 2010 Pages Using CSS

Hide Left Panel/Quick Launch From SharePoint 2010 Pages using CSS:
1.   Use Simple CSS classes to hide left panel
#s4-leftpanel
{ display:none; }
.s4-ca
{ margin-left:0px; }
2.   For single page level change, add Content Editor web part on the page and inject above script in HTML section of that web part.

For all pages in the site, use this script in master page.

Example:
<style type=”text/css”>
#s4-leftpanel
{ display:none; }
.s4-ca
{ margin-left:0px; }
</style>   

How To Get Worker Process Ids Of Application Pools IIS7 ?

To Get Worker Process Ids Of Application Pools IIS7:
  1.   Open Command Prompt With “Ran as administrator”
  2.   Change directory to “c:\Windows\System32\inetsrv
  3.   Enter “appcmd list wps” to get list of application pools to along with worker process id associated with it
Note: Make sure you have IIS7 installed in your machine to execute this command.
4.   Above command will give you output like:
WP “5057” (applicationPool:wkeyrgsdmaguykwegfk)
WP “6089” (applicationPool:SecurityTokenServiceApplicationPool)

Tuesday, June 4, 2013

Rating Not Reflecting In SharePoint 2010

The following two timer jobs are responsible to calculate and display current rating in SharePoint 2010.
-User Profile Service Application - Social Data Maintenance Job
-User Profile Service Application - Social Rating Synchronization Job

These jobs executes every 1 hour by default. If required those can be executed manually:
1. Open

“Central Administration à Monitoring à Timer Jobs à Review Job Definitions à User Profile Service Application - Social Rating Synchronization Job”

And

“Central Administration à Monitoring à Timer Jobs à Review Job Definitions à User Profile Service Application - Social Rating Maintenance Job”


2. Click “Run Now” or change the “Recurring Schedule” as required.