Posts

Open SharePoint Online site in SharePoint Designer with MFA (Multifactor authentication)

Image
How to open SharePoint online site in SharePoint Designer with MFA ? (Multi-factor authentication) Please do not forget to comment if this helps. Issue : SharePoint Designer does not support MFA Solution : While setting up MFA with O365, you must have received App password . Please use App password instead of regular network password/one time password. What if you don’t have/remember  App password  ? Please follow below steps to generate new  App password and use it for SPD. 1. Log into O365 from https://portal.office.com/ 2. Go to  https://account.activedirectory.windowsazure.com/r#/applications 3. Click of your name from right top -> "Profile" -> "Additional security verification" 4.   Go to tab “App Passwords” (Hidden tab : Follow screen shot) 5. Now you can create new  App password , just give a name and use it as you SPD password(you can also delete old if no longer required.) Keep...

Sharepoint : get all sites where feature is active at site or web level

Sharepoint : get all sites where feature is active at site or web level Please do not forget to comment if this helps. Get all Site Colletions where GUID matched to site colleation feature Get-SPSite -limit ALL | foreach{ $_.features["GUID"] } | select Parent Get all Webs where GUID matched to web feature Get-SPSite -limit ALL | Get-SPWeb -limit ALL | foreach{ $_.features["GUID"] } | select Parent

How to handle JavaScript post back in SharePoint 2010

Scenario : Run JavaScript on page load but not on postback. Why : SharePoint does field validation on server side so it runs page load js again. Please do not forget to comment if this helps. Please use below script to avoid same : $(document).ready(function() { if((window.location.pathname).toLowerCase().indexOf("new.aspx") > 0) { if((document.referrer).toLowerCase().indexOf("new.aspx") < 0) { ExecuteOrDelayUntilScriptLoaded(functionToCall, "sp.js"); } } }); function functionToCall() { alert('Just on page load'); }

How to get wsp/dlls/code from SharePoint deployed solution?

How to get wsp/dll/code from SharePoint deployed solution? Please do not forget to comment if this helps. Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $farm = Get-SpFarm $file = $farm.Solutions.Item("wsp_name.wsp ").SolutionFile $file.SaveAs("D:\Temp\wsp_name.wsp") reanme .wsp to .cab and extract DLL now you can use http://ilspy.net/ to see whats inside DLL. Enjoy

The file is locked for exclusive use by user... SharePoint

The file is locked for exclusive use by SharePoint Please do not forget to comment if this helps. Use below PS script to unlock document. (Will need farm admin access) $web = Get-SpWeb <SP Web URL> $item = $web.GetListItem("<Document URL including web>") #e.g : https://my.sp.com/sites/test1/2017/myPlan.xlsx $item.file.LockType $item.file.LockedByUser $item.file.LockExpires ## Unlock $userId = $item.File.LockedByUser.ID $user = $web.AllUsers.GetById($userId) $impSite = New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken); $impWeb = $impSite.OpenWeb(); $impItem = $impWeb.GetListItem("http:\\domain.FULLURL.com\FilaName.xlsx") $impItem.File.ReleaseLock($impItem.File.LockId) $web.dispose() $impWeb.dispose()

Sharepoint : create calculated column to get weekdays

=IF(ISERROR(DATEDIF([Start Date],[End Date],"d")),"",(DATEDIF([Start Date],[End Date],"d"))+1 -INT(DATEDIF([Start Date],[End Date],"d")/7)*2  -IF((WEEKDAY([End Date])-WEEKDAY([Start Date]))<0,2,0)  -IF(OR(AND(WEEKDAY([End Date])=7,WEEKDAY([Start Date])=7),AND(WEEKDAY([End Date])=1,WEEKDAY([Start Date])=1)),1,0)  -IF(AND(WEEKDAY([Start Date])=1,(WEEKDAY([End Date])-WEEKDAY([Start Date]))>0),1,0)  -IF(AND(NOT(WEEKDAY([Start Date])=7),WEEKDAY([End Date])=7),1,0))

Updating Date Time column in SharePoint 2010/2013 from C#

Updating Date Time column in SharePoint 2010/2013 from C#. DateTime.Now.ToString(“yyyy-MM-ddTHH:mm:ssZ”); spItem["MyDateTimeColumn"] = Microsoft.SharePoint.Utilities.SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now); //How to handle server time vs website time. spweb.RegionalSettings.TimeZone.UTCToLocalTime(DateTime.UtcNow);