In Salesforce Lightning I am trying to make a button on the case layout which assigns a case to the user viewing it. I want this button to be a single click and the case owner is reassigned and the page is refreshed to show the new owner. There are a lot of examples of this working with JavaScript in Salesforce classic but Salesforce Lightning does not support JavaScript buttons on layouts so I can not figure out how to accomplish this.
2 Answers
You can use a button that starts a flow, the flow can reassign the case and you can use a lightning web component on a flow screen with some javascript to refresh the page.
You can create an "update a record" action. Set the predefined value of Owner field to current user and remove all fields from layout.
This will allow you to have a 2 clicks update.
If you really want one click, you will need to make a headless quick action. This involves some development whereas the other method only use point&click.