SharePoint Button Triggering Action When Disabled

Yakout RAMZI 40 Reputation points
2025-06-12T19:37:40.1333333+00:00

I'm working with SharePoint JSON column formatting to create a custom button labeled "Envoyer Validation". The button is designed to have three color states: green (valid and complete data), yellow (incomplete data), and grey (already validated). However, the issue is that the button triggers a SharePoint update message status even when it is in the yellow or grey states, which should not happen. The intention is for the button to be clickable only when it is green (indicating valid data), and inactive for yellow or grey states, without triggering any action or message. How can the customRowAction be fully blocked in SharePoint when the button is not supposed to be active? Here is the JSON code being used:

{ 
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "txtContent": "Envoyer Validation",
  "style": { 
    "background-color": "=if([$Statut] == 'Validé', '#d6d6d6', if([$NomMedicament] && [$DateExpiration] && [$CodeProduit] && [$Fournisseur] && [$MedecinResponsable] && [$Posologie] && [$RemiseTotale] && ([$MotifPrescription] || [$TypeTraitement] == 'Traitement Prolongé' || [$TypeTraitement] == 'Traitement Ponctuel'), '#28a745', '#ffc107'))",
    "color": "white",
    "font-weight": "bold",
    "border-radius": "6px",
    "padding": "6px 12px",
    "cursor": "=if([$Statut] == 'Validé', 'not-allowed', if([$NomMedicament] && [$DateExpiration] && [$CodeProduit] && [$Fournisseur] && [$MedecinResponsable] && [$Posologie] && [$RemiseTotale] && ([$MotifPrescription] || [$TypeTraitement] == 'Traitement Prolongé' || [$TypeTraitement] == 'Traitement Ponctuel'), 'pointer', 'not-allowed'))",
    "pointer-events": "=if([$Statut] == 'Validé', 'none', if([$NomMedicament] && [$DateExpiration] && [$CodeProduit] && [$Fournisseur] && [$MedecinResponsable] && [$Posologie] && [$RemiseTotale] && ([$MotifPrescription] || [$TypeTraitement] == 'Traitement Prolongé' || [$TypeTraitement] == 'Traitement Ponctuel'), 'auto', 'none'))" 
  },
  "customRowAction": { 
    "action": "setValue",
    "actionInput": { 
      "Statut": "=if([$Statut] != 'Validé' && [$NomMedicament] && [$DateExpiration] && [$CodeProduit] && [$Fournisseur] && [$MedecinResponsable] && [$Posologie] && [$RemiseTotale] && ([$MotifPrescription] || [$TypeTraitement] == 'Traitement Prolongé' || [$TypeTraitement] == 'Traitement Ponctuel'), 'En Cours', [$Statut])" 
    } 
  } 
}
Microsoft 365 and Office SharePoint Development
0 comments No comments
{count} votes

Accepted answer
  1. Gabriel-N 1,715 Reputation points Microsoft External Staff Moderator
    2025-06-13T06:01:19.2333333+00:00

    Hi Yakout RAMZI 

    Thank you for posting your question in the Microsoft Q&A forum 

    In SharePoint, the double-click behavior on a list row is a built-in feature that automatically opens the item’s edit form. This behavior is "by design" and cannot be disabled or customized using JSON formatting or HTML-based methods. 

    This limitation exists because SharePoint’s JSON formatting is strictly declarative, it allows for styling and configuring UI elements, but does not support scripting or event handling (such as JavaScript). As a result, native browser or SharePoint events like double-clicks cannot be intercepted or overridden. 

    For more details, refer to the following official Microsoft resources: 

    To address this, we’ve implemented logic that ensures the following: 

    • The action button only becomes active when all required fields are completed and the item’s status is not already set to "Validé". 
    • If these conditions are not met, the button is displayed in yellow and is fully disabled for single-click interactions. 
    • We use pointer-events: none and customRowAction: "none" to effectively block any unintended actions or updates. 

    Below is the JSON formatting applied to the view to control the button behavior: 

    { 
    
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", 
    
      "elmType": "div", 
    
      "attributes": { 
    
        "role": "button" 
    
      }, 
    
      "style": { 
    
        "background-color": "=if([$Statut] == 'Validé', '#d6d6d6', if([$NomMedicament] && [$DateExpiration] && [$CodeProduit] && [$Fournisseur] && [$MedecinResponsable] && [$Posologie] && [$RemiseTotale] && ([$MotifPrescription] || [$TypeTraitement] == 'Traitement Prolongé' || [$TypeTraitement] == 'Traitement Ponctuel'), '#28a745', '#ffc107'))", 
    
        "color": "white", 
    
        "font-weight": "bold", 
    
        "border-radius": "6px", 
    
        "padding": "6px 12px", 
    
        "cursor": "=if([$Statut] == 'Validé', 'not-allowed', if([$NomMedicament] && [$DateExpiration] && [$CodeProduit] && [$Fournisseur] && [$MedecinResponsable] && [$Posologie] && [$RemiseTotale] && ([$MotifPrescription] || [$TypeTraitement] == 'Traitement Prolongé' || [$TypeTraitement] == 'Traitement Ponctuel'), 'pointer', 'not-allowed'))", 
    
        "pointer-events": "=if([$Statut] == 'Validé', 'none', if([$NomMedicament] && [$DateExpiration] && [$CodeProduit] && [$Fournisseur] && [$MedecinResponsable] && [$Posologie] && [$RemiseTotale] && ([$MotifPrescription] || [$TypeTraitement] == 'Traitement Prolongé' || [$TypeTraitement] == 'Traitement Ponctuel'), 'auto', 'none'))" 
    
      }, 
    
      "txtContent": "Envoyer Validation", 
    
      "customRowAction": { 
    
        "action": "=if([$Statut] != 'Validé' && [$NomMedicament] && [$DateExpiration] && [$CodeProduit] && [$Fournisseur] && [$MedecinResponsable] && [$Posologie] && [$RemiseTotale] && ([$MotifPrescription] || [$TypeTraitement] == 'Traitement Prolongé' || [$TypeTraitement] == 'Traitement Ponctuel'), 'setValue', 'none')", 
    
        "actionInput": { 
    
          "Statut": "=if([$Statut] != 'Validé' && [$NomMedicament] && [$DateExpiration] && [$CodeProduit] && [$Fournisseur] && [$MedecinResponsable] && [$Posologie] && [$RemiseTotale] && ([$MotifPrescription] || [$TypeTraitement] == 'Traitement Prolongé' || [$TypeTraitement] == 'Traitement Ponctuel'), 'En Cours', [$Statut])" 
    
        } 
    
      } 
    
    } 
    
    

    We hope the details provided will assist you effectively.


    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.


0 additional answers

Sort by: Most helpful

Your answer

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