Forum Discussion

AP_TC_ECASD's avatar
AP_TC_ECASD
Copper Contributor
Feb 06, 2024

Yes/No Toggle that Delete's Item

I have a Yes/No column that I've formatted as a usable Toggle, but I'm wondering if it's possible to have the toggle delete the item row when toggled to Yes?  Here is my current Column Formatting:  ...
  • ganeshsanap's avatar
    ganeshsanap
    Feb 07, 2024

    AP_TC_ECASD In that case, you can use the simple JSON like: 

     

    {
      "_comment": "Toggle Buttons",
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "attributes": {
        "iconName": "Delete",
        "class": "ms-fontColor-red"
      },
      "style": {
        "cursor": "pointer",
        "font-size": "35px",
        "display": "=if(@currentField,'none','block')"
      },
      "customRowAction": {
        "action": "delete"
      }
    }

     

    Also, delete confirmation popup will be shown by default - this is default functionality (or limitation) of SharePoint JSON formatting which we cannot customize.

     

    If you need a delete button against each row without confirmation, you cannot do it using JSON formatting. You will have to use the SPFx field customizer for such requirements - code/development experience is required.


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Resources