0

Conditional dialog() button

Hello,

Is there a way to make the choices of a dialog() function conditional?

I would like to create a button that allows me to contact my customers via different channels: Phone call, SMS, WhatsApp and email.

For example, I would like the suggestion to contact by email not to be displayed if I do not have the email entered in the 'E-mail principal' field.

I tried with a simple code but choice #4 which corresponds to the email is displayed like this: #4

let tel := 'Téléphone principal';
let mail := 'E-mail principal';
let title := "Canal de contact";
let message := "Quel canal de contact souhaitez-vous utiliser ?";
let answerOptions := [if tel then "Téléphone" end, if tel then "SMS" end, if tel then "WhatsApp" end, if mail then "Mail" end, "X"];
let resultat := dialog(title, message, answerOptions);
if resultat = "Téléphone" then
    null
end

 Thank you for your help

2 replies

null
    • Sviluppatore Ninox
    • Fabio
    • 4 wk ago
    • Reported - view

    Hello.
    Your code may be fine. You just need to insert a filter (line 6) to filter out undefined values from the array before passing it to the dialog() function. Here's how to do it:

    let tel := 'Téléphone principal';
    let mail := 'E-mail principal';
    let title := "Canal de contact";
    let message := "Quel canal de contact souhaitez-vous utiliser ?";
    let answerOptions := [if tel then "Téléphone" end, if tel then "SMS" end, if tel then "WhatsApp" end, if mail then "Mail" end, "X"];
    let filteredOptions := answerOptions[not null];
    let resultat := dialog(title, message, filteredOptions);
    if resultat = "Téléphone" then
       ...
    end

    Fabio

      • Créateur de bien-être
      • Sebastien_Guillet
      • 4 wk ago
      • Reported - view

       Oh merci, ça marche !