OneDrive for Business – Getting access of user’s OneDrive

If you have been using OneDrive for business then you should know that OneDrive behind the scene is SharePoint site collection which only users have access. For example I will be the Site Collection Admin on my OneDrive and no one can access my OneDrive unless I decide to share document or folder sitting in my OneDrive. This is perfectly fine as long as user is active.

What if user left the organization and you would want to get access. Once the user leaves the organization OneDrive is smart enough to give access of that OneDrive to user’s manager and gives them about two weeks to take any backup etc.

In other scenarios where user is active but running into some issues like lost files etc.

In both of the above cases you have another option to get user’s OneDrive as long as you are SharePoint Administrator on your tenant.

  1. Visit the SharePoint admin center using the URL https://tenant-admin.sharepoint.com/ (Replace tenant with your tenant name).
  2. Click on User Profiles and then click Manage User Profiles.
  3. Find the user and click “Manage Site Collection Owners” for that user using the dropdown menu.
  4. This would open the popup dialog where you would user is set as Primary Site Collection Owner as well as Site Collection Owner.
  5. You can simply add the backup person’s name under Site Collection Owner and click OK.

Now I have validated the above steps works just fine as long as user is active but in some cases when user is disabled the above steps does not work. It will let you add the Site Collection Owner but that change will not take place.

In that case you can user the following PowerShell to work around this issue.

$creds = Get-Credential

Connect-SPOService -Url "https://tenant-admin.sharepoint.com" -credential $creds

Set-SPOUser -Site "https://tenant-my.sharepoint.com/personal/USER/" -LoginName "[email protected]" -IsSiteCollectionAdmin $true

I hope this helps.

SharePoint Online – Column Formatting – Using different columns

I had earlier blogged about Microsoft Rolling out column formatting to the first release tenants and how it could be useful in many scenarios.

For anyone who wants to get started with column formatting following article is by far the best technical documentation.

https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting

Today I am going to talk about one specific scenario where you would want to use other fields data on the current item.

Most column formatting examples you would see are based on the current column where you could refer the column using @currentField. In some scenarios you would want to leverage other field values in the same item. e.g. If column X value is Y then change the background color of my current column.

So for this example I am going to have two columns i.e. Picture Column and HyperLink column.

What I want to do is when my items are displayed picture is clickable and it opens a URL in your HyperLink column and opens in a new tab.

Here is code.

{
 "elmType": "a",
 "attributes": {
 "href": "[$HYPERLINK_FIELD_NAME]",
 "target": "_blank"
 },

"children": [ 
 {
 "elmType": "img",
 "txtContent": "",
 "style":{
 "min-height": "initial",
 "margin-top": "0px"
 },
 "attributes": {
 "src": "@currentField", 
 "width": "100%"
 }
 }
 ]
}

Here I have element type <a> and then I am using element type <img> as the children. Most of the image element stuff you see around style is just to align it properly.

The key thing is element type <a> where I am setting href to other HYPERLINK column value and I reference that column by using the [$FieldName]. The column is formatted within the context of the entire row. You can use this context to reference the values of other fields within the same row.

I hope this helps.