Issue with SharePoint JSON Button: Green Button Not Triggering Action Despite Valid Conditions

Yakout RAMZI 40 Reputation points
2025-06-15T17:32:22.88+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 with this JSON formatting is that while the yellow and grey buttons are correctly non-clickable, the green button is also unresponsive. My objective is to ensure that only the green button is clickable when all required conditions are met, and the other buttons remain inactive as expected .

{

"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",

"elmType": "div",

"attributes": {

"role": "button" 
  }, 

  "style": { 

powershell
"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": { 

powershell
"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])" 

} 
  } 

Microsoft 365 and Office SharePoint Development
0 comments No comments
{count} votes

Accepted answer
  1. Teddie-D 1,030 Reputation points Microsoft External Staff Moderator
    2025-06-16T04:45:39.2366667+00:00

    Hi @Yakout RAMZI
    Thank you for reaching out to the Microsoft Q&A Forum. 

    Based on my testing environment, your JSON code is correct, and functions as expected. The green button becomes active only when all required fields are populated, and the other states behave as intended. 

    Additionally, I noticed you mentioned that the green button is also unresponsive. Could you please clarify this issue further? Understanding this will help us troubleshoot more effectively. 
    User's image User's image User's image

    However, to better understand why the green button might not be triggering the action in your environment, could you please confirm the default column types for the following fields? 

    • MotifPrescription 
    • TypeTraitement 
    • NomMedicament 
    • DateExpiration 
    • CodeProduit 
    • Fournisseur 
    • MedecinResponsable 
    • Posologie 
    • RemiseTotale 
    • Statut 

    In my setup, I configured these column as below types: 

    • MotifPrescription: Choice 
    • TypeTraitement: Choice 
    • NomMedicament: Text 
    • DateExpiration: Date and time 
    • CodeProduit: Text 
    • Fournisseur: Text 
    • MedecinResponsable: Text 
    • Posologie: Multiple lines of text 
    • RemiseTotale: Currency 
    • Statut: Text 

    Looking forward to your update so we can help you troubleshoot further. 


    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.