Save form prior to calling Flow from Button

Hello wonderful community!

First off, I’m not a developer, but I manage to get by. I’ve searched the forums, and have found similar posts, but the closest one did not provide any code examples.

I also found this article, but was unsure:

I am trying to solve an issue where the modified by is set to a system account because of a workflow that runs when a Sharepoint item is created or modified. The flow in question sets certain fields and more specifically takes the contents of the “notes” text field and prepends it to the existing field of “History” so that we record each time notes are entered. The flow runs under the context of a system account, so it sets the modified by as itself. That’s only an issue in this context when I use the completed button which calls another flow on top of the original one. The button flow just changes a couple of fields, but because it’s a button flow, I can use get user profile to identify who clicked the button. Unfortunately, the first flow runs async and so the prepended history note will not have the display name of the user that clicked the button, but the system account. WHEW!

What I’m trying to do is to have the completed button save the form first which will change the modified by to that current user, and THEN call the flow to mark everything complete. I think that will solve my issue. However, moving the above the call of the flow in the button click code will save the form, but doesn’t call the flow.

Can someone with a bigger brain help me to get this accomplished? I’ve tried attacking this from the flow standpoint and now from the forms standpoint.

Any help, or pointers in the right direction would be greatly appreciated!

Here is my current button code:

Hello @CBOI_GGriffin,

What is the need to call the flow when the button is clicked? Why don't you call the flow when the item is created or modified?

Also, from what I understood, the flow populates certain fields and adds Notes to the History field. All this can be done on the form, inside the spBeforeSave() event:

fd.spBeforeSave() {
fd.field('SPField').value = fd.field('CommonField').value

Another thing you can do is add discussion to the form for logging user comments.


Thank you for the response. To be honest, I didn't realize it could be done within the code of the form like that. As I said, i'm not a developer, which is why I'm using flows to build some of this automation. To answer quickly, with my limited knowledge, I've found that I need to have a different flow, that gets executed from the button, because it does different things than the flow that already runs after the item is modified. For example, the "Complete" button marks the status as complete, prepends information to the audit log field, notifies certain people via email, and a few other things. To have that done in the flow when it's modified or created would make that flow much more complex with a lot of condition items.

Again, I apologize for my naivety. The fd.spBeforeSave option is very interesting and would allow me to do a lot of the stuff I'm doing in the flow triggered by modified or created like take care of the history field, but it would need to be an IF statement so that it wouldn't put null items in it, because sometimes the ticket is modified but no notes are added.

I didn't want to add discussion to the form because I wanted to have readily available access to that data to help build a knowledge base and I simply don't know how to grab the discussion data. I originally had versioning turned on for the notes field, but that data, while it shows with the user and timestamp, isn't retained if the item gets moved, i.e. I archive the list because we have 5k items in it.

Again, I greatly appreciate some different directions on this, and you've helped me out. I know there are always a hundred different ways to do anything in development, and I appreciate you offering some of those. If there is anything in this or my goals that I can clarify, please let me know.

If anyone else has any suggestions on how you've done something like this, I'd love to know that as well. I also found this article that I'll be looking at as well to make a https post call back to the item to change it's MetaData of the modified by.

Thanks again and if anyone else has any thoughts or suggestions, I'd love to hear them.


Another thing I might suggest is to replace the flow that is triggered on button click with the flow triggered depending on a field value.

For example, you can add a TriggerFlow column. When the user clicks the button, the TriggerFlow value will change to true and the form will be saved. In the flow, add a condition to check the TriggerFlow value before the other steps. This way, the flow will be triggered, but the actions will be executed when a certain condition is met.

If you want to use the POST method to start a flow, you better address this question to the Microsoft Community.