Wednesday, September 2, 2020

Copy SharePoint files and retain Created By and Modified using a Power Automate Flow

 The Problem

 I've seen crop up in searches and I have seen it on Microsoft Tech community where people want to copy files somewhere for multitude of reasons but want to retain the created by and modified by information. Current methods do not retain information when a copy is used. 

Existing Methods

Using a Power Automate Flow's built in "Copy File" copies files across sites and libraries no problem. However, the person triggering the flow or the account the trigger is built on becomes the created by / modified by after the copy completes since it's creating a new file for the copy. 

The "Move file" action works, but it does not retain the original file in it's original location which is a requirement in many cases when copying files somewhere for archive or other purposes. 

CreateCopyJobs to the Rescue

After looking around for REST calls that might work, I stumbled across the newer option which utilizes the same mechanics that "Move to" and "Copy to" use in SharePoint Modern pages. I thought originally that "Copy to" retained metadata but after testing it, it does not. I started looking at the properties for this call and noticed at the very end a property called "MoveButKeepSource"

public bool MoveButKeepSource { get; set; }

Once set, this move operation is similar to copy. The file will move to destination, but the source content will not be deleted. If set, this will make a copy with the version history and preserve the original metadata. No source item deletions occurs at the end.


Well, this is interesting. What this means is we can basically use the Move method but retain the original which in effect acts as a copy, but it will retain the metadata like a move to will. This is perfect! Now how do we get that into effect?  

Here is a reference to the CreateCopyJobs Docs article. 

The Flow

This is a very simple 2 step flow. Step 1 is the trigger, either a manual method using "For selected item" or you can have it automatically copy based on created / modified of files in a library. Step 2 is a "Send HTTP Request to SharePoint" action. 

Below is my  example flow that I used to get this working.

Here is the Body I used for this update, I hardcoded the destination and what not but if you need to make this dynamic for some reason you could easily do this. Just make sure you input your destination URL to the library without the trailing / as you will get an error if you include that. 

Body: 
   "exportObjectUris":[  
      "Link_to_Item_Goes_Here"
   ],   "destinationUri":"https://yourtenant.sharepoint.com/sites/your_site/Shared%20Documents",
"options":{
"IgnoreVersionHistory":false,
"IsMoveMode":true,
"MoveButKeepSource":true,
"AllowSchemaMismatch":true,
"NameConflictBehavior":1
}
}

I have the options set so that version history moves over, movemode tells this to use move instead of copy which will retain metadata, MoveButKeepSource is the key that keeps a copy and moves a copy. AllowSchemaMismatch is you have different columns in the libraries, I put this in as any changes to columns and you will get a badgateway error so best to have this in place. NameConflictBehavior is 1, this will replace existing files with the same name. If you want to create a copy instead you can specify a 2 and it will append a number to the end of the document name. 

Conclusion

I hope this helps anyone out there that has this requirement of copying files somewhere and wanting to retain metadata from an automated method or you just want to copy files and retain the Created by / Modified  by columns since utilizing the built in "Copy to" doesn't seem to do that. 

Friday, March 6, 2020

Microsoft Teams Suggested and Trending Notifications and How They Can Cause Confusion




New Suggested and Trending Notifications in Microsoft Teams

Microsoft has started to sneak in a feature into Teams that gives notifications for trending and suggested threads throughout your various Teams you are a member of. These are notifications to help you get more involved and not miss out on content in your Teams designed to help you reduce notification settings and keep you in the loop but it seemingly is causing more confusion than it is helping users with their Teams and notification noise.

Why Are Notifications Showing for Channels That Are Set Off?

There are many Tech Community posts and mumbling about that users are getting confused because they are receiving notifications in their activity feed despite them setting these channels notifications to "off".

On close inspection, you will notice that these notifications have new icon's next to them to let you know what the source of the notification is. Instead of the usual icons for reply, mention etc. you will have the following new icon's for Suggested and Trending notifications in the feed. 

These types of notifications do not follow the same rules as your channel notification settings and can make it seem that your notification settings are not working even thou they are for the normal notification types, but these new notification types override your settings. 


How can I disable these? 

Luckily Microsoft has provided ways of disabling these notification if you do not want them. Below you can find out how you can disable this for yourself. Or how the tenant admin can disable these for everyone with the click of a mouse. 

Per User: 

Each user has the ability to disable the suggested and trending notifications in their notification settings. In the settings window on the notifications tab, you can find trending and suggested as shown and set how you wish to be notified of these actions. **If you do not have these they have not been pushed to your tenant**






Org-Wide: 

Your tenant admins have the option to disable this for all users by disabling the following feature in Org Wide Settings > Team Settings > Notification and Feeds section, You have an option to disable Suggested feeds which should include Trending and Suggest notification types. This should disable it for your entire Org. 



Hopefully this will help you when this feature lands and your users are confused to why they are getting notifications for posts they shouldn't be getting them for. This feature can help with setting up less notifications but stay up on trending topics, however most users are used to being in control of what they want and don't want to see. The good news is Microsoft has given us a choice in this matter and not forced the notifications on us, so good job Microsoft for that, I just wish it was a bit more obvious than an icon to the users why they are getting these seemingly random notifications in their feeds.