Confirm/Cancel buttons in promptcommand

When I use Prompt command, I can close message with “Cancel” button or “Confirm” button or “X” button.

When I read explanations about prompt command, I understand that it is impossible to know which button is used to close message.

So an unique button like “Ok” one seems less ambiguous.

Actually, you know which button is pressed. The input value is only returned with “Confirm”, otherwise the value is “null”

  • Cancel button => returned value = “null”
  • X icon => returned value = “null”
  • Confirm button => input value

Super. I am going to use it!

If cancel button is used (or X), the returned value is a string literally called “null”? You put it in quotes.

How does one differentiate between a Cancel/X and a blank submission (or someone typing “null”)?

Just to clarify for anyone else… if you’re looking to check if the cancel or X icon were pressed you need to to an if command looking for null, not “null”. For example:

    {
      "Command": "prompt",
      "Target": "Are you clicking Confirm? ",
      "Value": "decision",
      "Description": ""
    },
    {
      "Command": "if_v2",
      "Target": "${decision} != null",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "throwError",
      "Target": "you clicked Cancel or X",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "else",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "throwError",
      "Target": "you confirmed",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }

If you put “null” in quotes in your if statement, then it will only be true if the user actually types the word null in the input field.

Thanks so much for this!

But I think your conditional logic is backwards… Your code is checking if decision is NOT null. If so, error says “you clicked Cancel or X.” The conditional should check if decision IS null (==).

{
    "Command": "if_v2",
    "Target": "${decision} == null",
    "Value": "",
    "Description": ""
},