Feb 02 2022 11:31 PM
Hello,
I have flow that automatically runs if a certain column is changed in a list. The value of the field gets changed from "in stock" to "used" and triggers the flow that enters the current date into another column.
Unfortunately this also changes the "modified by" column back to my name because it it "my" flow that runs and the name of the person that changed the used/instock field gets overwritten.
Is the a way the keep the name of the person that changed the used/in stock field?
Feb 03 2022 12:09 AM
@MichaelMr No you can't change that behaviour, you would need a different column for holding the details of who had changed the used/in stock column.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
Feb 03 2022 12:19 AM
Feb 03 2022 01:39 AM - edited Feb 03 2022 01:41 AM
@MichaelMr The flow for this is quite simple and you don't need parallel branches. But first you MUST make sure you have turned on item version history in the list settings as the flow needs to compare the current version with the previous version.
In this example we have a column for whether the item is in stock or used, A Date/Time column for the date it was changed from in stock to used and a single of texct column for who made that change. We are going to change the Bedar item.
The overall flow looks like this
So, the trigger is "when an item or a file is modified" and you select the site and list.
The first action is "get changes for an item or a file (properties only)". For the ID field you select ID from the dynamic content box. For the Since field you need to add the following expression into the Expression tab in the dynamic content box. This expression is what compares the current version to the previous one:
sub(int(triggerOutputs()?['body/{VersionNumber}']),1)
Next add a condition. From the dynamic content box select "Has column changed: Used", select is equal to and type in true
If that column HASN'T changed then we don't want the flow to do anything, so the red if no channel can be left empty.
But if the Used column HAS changed then in the green if yes channel add an update item action. Select ID, Title and any other required column from the dynamic content box. For the DateChanged column add an expression of utcNow() which means today. For the ChangedBy column I selected Modified By display Name, but you could select Modified By Email if you preferred.
The Bedar item was changed to Used, the flow ran and after a few seconds the ChangedDate and ChangedBy columns were updated (you might need to refresh the list to see the change).
Rob
Los Gallardos
Microsoft Power Automate Community Super User
Feb 03 2022 05:41 AM
The SharePoint connector does not have this ability; however, the Dataverse one does.
Just point this out in case this is an option.
Feb 03 2022 08:04 AM
Feb 03 2022 08:43 AM
@MichaelMr which action in the flow results is giving that error?
Rob
Los Gallardos
Microsoft Power Automate Community Super User
Feb 03 2022 09:13 AM
@MichaelMr This is a known behavior if you are updating the list item from flow using Standard SharePoint connector action.
If you want to set the name of user who changed the list item in Modified By field, you can use ValidateUpdateListItem API call to update list item from flow.
Check this article for more information: modifying Modified By and Modified time with Microsoft Flow
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Feb 03 2022 09:15 AM
@ganeshsanap that hasn't worked for over year as far as I remember from other forum posts.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
Feb 03 2022 12:33 PM
Feb 04 2022 12:07 AM
@MichaelMr if you could show (in edit mode) both the trigger and the first action that would probably help me solve it. Thanks.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
Feb 04 2022 02:02 AM
Hi Rob,
of course:
first step is to set the trigger,
second one is the step from your post,
third step to create a timestamp for my "date used" column,
then the conditions: "used" column hast to be "used", "date used" column has to be empty,
and the condition from your post "... has changed"
Feb 04 2022 02:07 AM - edited Feb 04 2022 02:08 AM
@MichaelMr the error is because you have typed the "Since" expression directly in the field which is incorrect. Click in the field and over in the dynamic content box click the Expression tab. Enter the expression there and click OK. This was shown in my earlier screenshots but is shown again below.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
Feb 04 2022 03:58 AM
Hi Rob,
thank you. That solved the problem.
One additional question:
The flow works fine as long as the original "modified by" column is visible in the list. If I hide the "modifiedy by" colum the flow runs without error but nothing is entered in the new "ChangedBy" column.
How can I solve this?
Feb 04 2022 06:24 AM
@MichaelMr there must be some other issue, I didn't have the Modified BHy column visible in my list.
Rob
Los Gallardos
Microsoft Power Automate Community Super User