No internet connection
  1. Home
  2. How to

How to copy the contents of a prompt dialog to a variable

By Andrew Sherman @Andrew_Sherman
    2021-05-25 11:19:30.456Z

    I'd like to have a dialog prompt at the beginning of one of my scripts. How do I get the contents of this as a string (entered by the user) and assign it to a variable?

    sf.interaction.displayDialog({
        defaultAnswer: "Client-Brand-PersonName",
        buttons: ["Enter", "Cancel"],
        defaultButton: "Enter",
        cancelButton: "Cancel",
        prompt: "Enter details",
        giveUpAfterSeconds: 5,
    });
    
    Solved in post #2, click to view
    • 5 replies
    1. Just take the text output property :)

      
      var text = sf.interaction.displayDialog({
          defaultAnswer: "Client-Brand-PersonName",
          buttons: ["Enter", "Cancel"],
          defaultButton: "Enter",
          cancelButton: "Cancel",
          prompt: "Enter details",
          giveUpAfterSeconds: 5,
      }).text;
      log(text);
      
      ReplySolution
      1. AAndrew Sherman @Andrew_Sherman
          2021-05-25 12:52:47.579Z

          Great, thank you Christian

          1. In reply tochrscheuer:
            AAndrew Sherman @Andrew_Sherman
              2021-06-17 13:38:28.834Z

              Hi Christian,

              Is there a way to get multiple different variables from a dialog (or filling in a form)?

              1. Not currently - not without building a SF app, but that requires having gone through our developer program which is currently invite-only.

                1. AAndrew Sherman @Andrew_Sherman
                    2021-06-17 14:22:10.335Z

                    Ok no worries, I can do what I want a different way, thanks.