Posts

ECMA Script : To get current logged in user information from User Profile Service Application

ECMA Script to get current logged in user information from User Profile Service Application using "SP.UserProfiles" script files. <!--script src="/_layouts/15/Scripts/MicrosoftAjax.js" type="text/javascript"></script--> <!--script src="/_layouts/15/init.js" type="text/javascript"></script--> <script src="/_layouts/15/sp.runtime.js" type="text/javascript"></script> <script src="/_layouts/15/sp.js" type="text/javascript"></script> <script src="/_layouts/15/SP.UserProfiles.js" type="text/javascript"></script> <script type="text/javascript">     //$(document).ready(function(){         SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js');     //});     var userProfileProperties;     function getUserProperties() {         var clientContext = new SP.ClientConte...

ECMA Script : To Add current logged in user to SharePoint group 2013/ 2010

<html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/ecmascript"> ExecuteOrDelayUntilScriptLoaded(init,'sp.js'); var currentUser; var currentUserName; var currentUserEmail; var currentUserLogin; var siteUrl = '/'; function init(){     var clientContext = new SP.ClientContext.get_current();     var oWeb= clientContext.get_web();           currentUser = oWeb.get_currentUser();     clientContext.load(currentUser);     clientContext.executeQueryAsync(Function.createDelegate(this,this.onQueryUNSucceeded), Function.createDelegate(this,this.onQueryUNFailed)); } function onQueryUNSucceeded() {   currentUserName = currentUser.get_title(); currentUserLogin= currentUser.get_loginName(); currentUserEmail= currentUser.get_email(); document.getElementById('txtUserName').innerHTML =  currentUserName; document.getElementById('txtloginName').innerHTML =  curr...

Get relative path and name of the active Script in PowerShell

# Get complete file path (eg: D:\RootFolder\ActiveScript.ps1) $0 = $MyInvocation.MyCommand.Definition # Get current Directory file path (eg: D:\FolderA) $dp0 = [System.IO.Path]::GetDirectoryName($0) #To Get the root folder $RootPath = $dp0 | split-path # Get current Drive (eg: D:\) $bits = Get-Item $dp0 | Split-Path -Parent

Check Running Timerjob Status using Powershell

Check the status of timer jobs that have been run by using Windows PowerShell. $Job = Get-SPTimerjob "TimerJob Name" [Array] $JobHistoryList=$Job.HistoryEntries Start-SPTimerJob $Job Write-Host "Running Timer Job" -NoNewline $count = $JobHistoryList.count $countNext = $count+1 while ( $countNext -ne $count) { [Array] $JobHistoryList=$Job.HistoryEntries $count = $JobHistoryList.count Write-Host "." -NoNewline sleep 2 } if ($taxonomyjob[0].status –ne "Succeeded") { Write-Host -f yellow $JobHistoryList[0].status Write-Host -f yellow $JobHistoryList[0].ErrorMessage } else { Write-Host $JobHistoryList[0].status }

"The Selected file was not found” Error When Adding an Attachment to an InfoPath Form

Adding the following bit of JavaScript to the WrkTaskIP.aspx page, which is responsible for hosting the InfoPath task form: <script type="text/javascript"> aspnetForm.encoding = "multipart/form-data"; </script> Another approach documented here suggests modifying the application.master master page file to add the necessary enctype form tag: <form runat="server" onsubmit="return _spFormOnSubmitWrapper();" enctype="multipart/form-data"> ... </form

Embedding InfoPath Form in SharePoint Page

Add the following line in the <SafeControls> tag of the web.config file of your web application in all servers: <SafeControl Assembly="Microsoft.Office.InfoPath.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.Office.InfoPath.Server.Controls" TypeName="*" Safe="True" /> Open Portal. Under Site Actions, click Site Settings. In the Site Settings page click Web Part Gallery link. In the Web Part Gallery page , click New. We will be redirected to the Web Part Gallery : New Web Parts facility. In the Web Part Gallery : New Web Parts part, check Microsoft.Office.InfoPath.Server.Controls.XmlFormView . Then, click Populate Gallery. We will be redirected again to the Web Part Gallery page where we can verify the inclusion of XmlFormView.webpart. Now open the page where you want to add the infopath form In the Site Actions, click Edit Page. the page will be set to Edit Mode. Cli...

WebPart Life Cycle

1. OnInit: event used to create controls of web part 2. OnLoad: 3. CreateChildControls: event used to set properties and default values to controls collection If the page is being rendered for the first time the method generally occurs after the OnLoad event. If it is Postback, It is called before OnLoad event. EnsureChildControls: It checks to see if the CreateChildControls method has yet been called, and if it has not, calls it. 4. LoadViewState: The view state of the web part is populated over here. 5. OnPreRender: event used to set up business logic related work and in this routine controls value kept by viewstate 6. Render: event creates the HTML that appears in the body of the Web Part. 7. OnUnload: 8. Dispose: