0

I have a formatted Single Line Text field in a SharePoint Library. It is formatted to be a button that executes a Flow. I've created this so I can attach this one flow to multiple libraries. It works well for that purpose, but I need it to perform an additional action: update a different field for the current item.

There are 2 other fields:

  • Publishing_Status (choice)
  • Last_Published_Date (Date and Time)

Is it possible with a button like below to update the value of another field? Specifically to add a time stamp and select a choice for the choice field?

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column- formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
  "action": "executeFlow",
  "actionParams": "{\"id\": \"ffa62926-6bbc-4db1-a409-1aeac8fdde93\"}"
  },
  "attributes": {
     "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
  },
 "style": {
   "border": "none",
   "background-color": "transparent",
   "cursor": "pointer"
 },
 "children": [
 {
  "elmType": "span",
  "attributes": {
    "iconName": "Flow"
  },
  "style": {
    "padding-right": "6px"
  }
},
{
   "elmType": "span",
   "txtContent": "Publish"
  }
 ]
}

I wanted to use Flow to update the item, but as it may come from one of several libraries, it's not really possible (as far as I can tell).

Thanks.

3
  • You can't update data from JSON view formatting, but I don't see any reason why your Flow couldn't do it. No matter what item triggers the Flow, you can always use the Update Item to update an item in another list, as last long as the connection account your Flow is using has access, it could even be in a different site. If you don't have the ID of the item you want to update, you can use the Get Items action with an OData filter to find it by other metadata criteria.
    – willman
    Feb 19, 2020 at 12:29
  • Thanks @willman, the only problem is I need to update the metadata of the item. And I can't make that dynamic, right? Like, I have the ID of the document I need to update, I also have the site and the library name - but all those variables will be dynamic. So I can't create the Update File Properties action, because Flow doesn't know what columns are in that list, because it's dynamic.
    – Sylvie
    Feb 19, 2020 at 12:35
  • I understand where your difficulty lies now, I posted an answer that should let you achieve it through Flow.
    – willman
    Feb 19, 2020 at 12:53

1 Answer 1

1

The Flow designer for the Update Item action does limit you to "known" fields, which is frustrating because it is only a UI restriction. If you were to go through the process of exporting the JSON of your Flow, editing the JSON manually, and re-importing, you could use Update Item with entirely dynamic values. I do not recommended that for this simple operation as that would be a cumbersome process, and there is an easier workaround.

Use the Send an HTTP Request to SharePoint to use the REST API directly. You can use it whether you need to Create a new item in a list or Update and existing one. Every single part of that action can be a dynamic value, from the SiteURL and API path, to the headers and body. Follow that documentation to format the JSON of your POST body, and for most of your headers, although you can skip the Authorization, Digest, and content-length headers, as Flow will handle those for you.

3
  • Thanks again @willman. This gets me a bit closer. I just need to be able to get the ListItemEntityTypeFullName from the list. I have managed to run a GET first, to retrieve this, but then I can't seem to use it in my next action. I tried this: {'__metadata': {'type': '@{body('Send_an_HTTP_request_to_SharePoint')?['entity']?['type']}'},'Publishing_Status':'Published' } as a shot in the dark, but it didn't work. Any idea?
    – Sylvie
    Feb 20, 2020 at 14:33
  • 1
    try @{body('Send_an_HTTP_request_to_SharePoint')?['d']?['__metadata']?['type']}. Note that if the Flow successfully executed the HTTP Request action, you can always go into that instance of the run history and expand that step to see the exact JSON of it's output, the go back to edit mode to adjust accordingly.
    – willman
    Feb 20, 2020 at 14:40
  • You are a national treasure.
    – Sylvie
    Feb 20, 2020 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.