0

In old versions of SharePoint (classic lists, SP 2013, SP 2016) it was possible to create a button via calculated column that changes the value of a column in this item instantly (example at the end of this post if anyone is looking for that solution).

Is there a way to update a column instantly via button in modern Lists without using Microsoft Flow? Flow needs some more clicks and needs some time to react. Hope to see a option that updates a column value directly.

EDIT: I am aware of the solution to start a Power Automate Flow from the List via JSON Button. This takes some time and makes it impossible to change multiple items within seconds. Am looking for another way that is maybe available somehow.

This is the solution for classic lists as mentioned above: just paste it into a calculated column as number and it will update the column "Column1" with the text on the button:

="<div style=""display:inline-flex;"">
"&"<button style=""float:left;
"&"cursor:pointer;width:75px;
"&"background:"&"white"&";"" 
"&"onclick=""{event.stopPropagation();
"&"this.parentNode.parentNode.parentNode.parentNode.style.backgroundColor=this.style.background;
"&"var C=SP.ClientContext.get_current(),
"&"I=C.get_web().get_lists().getById(SP.ListOperation.Selection.getSelectedList()).getItemById(
"&"this.parentNode.parentNode.parentNode.parentNode.id.split(',')[1]"&");"&"C.load(I);
"&"I.set_item('Column1',this.innerHTML);"&"I.update();"&"C.executeQueryAsync();
"&"return false;} {window.location.reload()}"""&">UPDATE</button>"&"</div>
"&"<img src=/_layouts/images/blank.gif >"

1 Answer 1

1

HTML markup is not supported in SharePoint online. So, you cannot use HTML formatted calculated columns in modern experience.

Source: Handling HTML markup in SharePoint calculated fields


Few options to check:

  1. SPFx Field Customizer: Provides modified views to data for fields within a list.

    Sample solutions: Check these samples to get the idea of how to updated item using field customizer.

  2. Microsoft flow with JSON formatting: I know you already mentioned that this takes some time to run flow. But, this is one of the supported solutions in SP online for such requirements.

Using above two options you can add button in column in list view & update column values.


Update:

In regard to JSON formatting, specifically, you can use setValue, see:

SharePoint JSON formatting syntax reference - customRowAction

Example:

{
  "elmType": "div",
  "txtContent": "[$FieldName]",
  "customRowAction":{
    "action": "setValue",
    "actionInput": {
      "FieldInternalName_1": "FieldValue_1",
      "FieldInternalName_2": "FieldValue_2",
    }
  }
}
5
  • I know it is not supported in modern lists, that is why I am asking for help with my question. Thank you for your reply. As I am aware of the solution to add a JSON Button to run a flow - which takes endless seconds compared with the HTML markup solution that worked for old SharePoint lists - that is why I was asking for another way to accomplish it without starting a Flow.
    – PhilFancy
    Oct 25, 2021 at 11:25
  • Yes, I understood your concern here. But, these are the limitations from Microsoft for modern experiences. So, I tried to mention all possible ways (which I know) for achieving your requirements. You can also check the SPFx field customizer solution which might work for you. Oct 25, 2021 at 11:29
  • Also, if you want to update multiple "list items" at a time from list view, you can also build ListView Command Set extension which will allow you to select multiple list items at a time & run APIs/code on click of button (list view command) at the top of list view. I am just trying to help with all the possible solutions I know. Let me know if these does not work for you. Oct 25, 2021 at 11:32
  • Check above sample solution under "SPFx Field Customizer" as well. Oct 25, 2021 at 11:42
  • 1
    Thank you for updating your reply. I see SPFx Field Customizer is a possible way of solving the issue. Thank you!
    – PhilFancy
    Oct 25, 2021 at 11:49

Your Answer

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

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