How to make a button/hyperlink change appearance and become inactive once it has been clicked?

Caoimhe Fitzgerald 1 Reputation point
2021-12-17T11:51:31.403+00:00

Hello,

I was watching a video from the Microsoft Sharepoint Conference 2019 (How to Start Using the Full Power of SharePoint Lists - SPC19), linked here: https://youtu.be/3pTMXx_ZFgY .

At minute 43, the presenter shows a "customer contact" column which he has formatted to include a button that sends an email, and then once clicked changes from an "active" state of a blue button to an "inactive" state of green text ("Follow up complete").

I'm new to Sharepoint and I can't find the code to make this happen anywhere. I would love to include this functionality in my project if I can.

Can you help me or point me in the right direction write the JSON? Thanks!

Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

1 answer

Sort by: Most helpful
  1. Yi Lu_MSFT 17,626 Reputation points
    2021-12-21T09:52:04.32+00:00

    Hi @Caoimhe Fitzgerald
    You could format the column (test) with this code:

    {  
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",  
      "elmType": "div",  
      "children": [  
        {  
          "elmType": "button",  
          "customRowAction": {  
            "action": "executeFlow",  
            "actionParams": "{\"id\": \"001a3379-8796-4c5c-bcd6-7b77fb0b7ccd\"}"  
          },  
          "attributes": {  
            "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"  
          },  
          "txtContent": "Start the Automate",  
          "style": {  
            "display": "=if([$name]=='sent','none','inherit')"  
          }  
        },  
        {  
          "elmType": "span",  
          "style": {  
            "padding-right": "8px",  
            "display": "=if([$name]=='sent','inherit','none')"  
          },  
          "txtContent": "@currentField"  
        }  
      ]  
    }  
    

    This format need to combine with a flow:

    159313-image.png

    Here you also need to change the flow ID in the code "actionParams": "{\"id\": \"001a3379-8796-4c5c-bcd6-7b77fb0b7ccd\"}" according to your flow, you could find your flow ID here:

    159187-image.png

    As a result, you will see a button "Start the Automate" in column "test", then it will send a mail automatically, and the value in column "result" will turn to "sent", and the button "Start the Automate" will turn to "finish":

    159342-image.png

    159324-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.