0

Retrieve the data from a button variable

Hello!

I have a database in which I have a table "Dashboard" which is the page that displays when I open Ninox and another table "Accounts" containing all the contact details of my customers.

When it's my clients' birthday, I manually go to each client's file in the "Accounts" table then I click on a "Birthday" button that I created which sends an email to wish a birthday.

Instead, I would like to have a button on the dashboard that will automatically send an email to all birthday customers. So far, I know how to do it. However, I would like the content of the email to be taken from the button in the account rather than having to re-enter it myself in the button on the dashboard.

Is it possible ?

Example of button:

let title := « Birthday »;
let message := "Do you really want to send the email?";
let answerOptions := ["Ok", "Ko"];
if dialog(title, message, answerOptions) = "Ok" then
let sample1 := (select Accounts);
for loop1 in sample1 do
if loop1.’Birthday’ = true then
sendEmail({
from: loop1.Entreprise.'E-mail',
to: loop1.'E-mail principal',
subject: "Happy birthday",
text: loop1.'Birthday button’.’text_birthday’,
})
end
end
end

Where « text_birthday » corresponds to let text_birthday = "content email" in the "Birthday button" of the Accounts table.

If it is not possible to retrieve the data from a button variable, will it be possible to retrieve the variable from a formula field?

Thanks for your help

6 replies

null
    • Fred
    • 2 mths ago
    • Reported - view

    Or you could put the code from the button that generates the text into your loop.

      • Créateur de bien-être
      • Sebastien_Guillet
      • 2 mths ago
      • Reported - view

       The button containing the "text_birthday" variable is found in the Accounts table then in the button named "Birthday button":

      let text_birthday := "Bonjour" + if 'Prénom' then " " + 'Prénom' end + "," + "<br><br>" +
          "En cette journée exceptionnelle, je tiens à " +
          if Courtoisie = 2 then "t'adresser" else "vous adresser" end +
          " mes vœux les plus chaleureux pour un joyeux anniversaire ! C'est avec une grande joie que je saisis cette occasion pour " +
          if Courtoisie = 2 then "te" else "vous" end +
          " souhaiter bonheur, santé et paix intérieure." +
          "<br><br>" +
          "" +
          if Courtoisie = 2 then "Ton" else "Votre" end +
          " bien-être est ma priorité, et je suis honoré de " +
          if Courtoisie = 2 then "t'accompagner" else "vous accompagner" end +
          " dans " +
          if Courtoisie = 2 then "ton" else "votre" end +
          " parcours vers une meilleure santé et un équilibre intérieur. Que ce jour d'anniversaire " +
          if Courtoisie = 2 then "t'apporte" else "vous apporte" end +
          " une dose supplémentaire de joie et de vitalité." +
          "<br><br>" +
          "C'est grâce à des clients exceptionnels comme " +
          if Courtoisie = 2 then "toi" else "vous" end +
          " que je continue à faire grandir mon entreprise et à offrir mes soins de bien-être. J'espère que " +
          if Courtoisie = 2 then "tu as" else "vous avez" end +
          " apprécié nos séances ensemble et que " +
          if Courtoisie = 2 then "tu as" else "vous avez" end +
          " ressenti les bienfaits pour " +
          if Courtoisie = 2 then "ton" else "votre" end +
          " corps et " +
          if Courtoisie = 2 then "ton" else "votre" end +
          " esprit." +
          "<br><br>" +
          if not 'Prochaine interaction' then
              "Si " + if Courtoisie = 2 then "tu as" else "vous avez" end +
              " des questions, des préoccupations ou si " +
              if Courtoisie = 2 then "tu souhaites" else "vous souhaitez" end +
              " planifier une prochaine séance de bien-être, " +
              if Courtoisie = 2 then "n'hésites" else "n'hésitez" end +
              " pas à me contacter ou à réserver en ligne directement sur mon site internet."
          else
              "Si " + if Courtoisie = 2 then "tu as" else "vous avez" end +
              " des questions ou des préoccupations, " +
              if Courtoisie = 2 then "n'hésites" else "n'hésitez" end +
              " pas à me contacter. J'ai hâte de " +
              if Courtoisie = 2 then "te" else "vous" end +
              " retrouver pour notre prochain rendez-vous."
          end +
          "<br><br>" +
          "Une fois de plus, joyeux anniversaire ! Je suis honoré de faire partie de " +
          if Courtoisie = 2 then "ton" else "votre" end +
          " voyage vers un mode de vie plus sain et plus épanouissant. ";

      I would like this variable to be able to be retrieved to apply in another button which will be used to send emails from another table whose code would look like this:

      let title := « Birthday »;
      let message := "Do you really want to send the email?";
      let answerOptions := ["Ok", "Ko"];
      if dialog(title, message, answerOptions) = "Ok" then
      let sample1 := (select Accounts);
      for loop1 in sample1 do
      if loop1.’Birthday’ = true then
      sendEmail({
      from: loop1.Entreprise.'E-mail',
      to: loop1.'E-mail principal',
      subject: "Happy birthday",
      text: loop1.'Birthday button’.’text_birthday’,
      })
      end
      end
      end
      

      I hope to have answered your question.

      • Fred
      • 2 mths ago
      • Reported - view

      Try:

      from: loop1.Entreprise.'E-mail',
      to: loop1.'E-mail principal',
      subject: "Happy birthday",
      text: "Bonjour" + if loop1.'Prénom' then " " + loop1.'Prénom' end + "," + "<br><br>" +
          "En cette journée exceptionnelle, je tiens à "
      

      Since loop1 is the Account record, you just need to put it in front of any field that you reference in the code that you bring over.

      Try it out on a test email.

      • Créateur de bien-être
      • Sebastien_Guillet
      • 2 mths ago
      • Reported - view

       

      I have difficulty expressing my problem. I'll try to make it simpler.

      I have a button1 in which there is the variable:

      let text_birthday := "Hello!"
      

      I also have a button2 which I use to send emails:

      sendEmail({
          from: Entreprise.'E-mail',
          to: 'E-mail principal',
          subject: "Happy birthday",
          text: button1.'text_birthday'
      })
      

      However, I would like the text section to return the information from the "text_birthday" variable of button1 -> example : button1.'text_birthday'

      • Fred
      • 2 mths ago
      • Reported - view

      I think I get it. You can't access information in a button. Your button writes to the field 'text_birthday' you can access data in that field.

      That is why I said to move the code from your button into the button on the dashboard. I'm guessing you don't always have data in 'text_birthday' so you need to make sure there is always text available.

      • Créateur de bien-être
      • Sebastien_Guillet
      • 2 mths ago
      • Reported - view

       

      Too bad!

      I was hoping to be able to use the same variable on several buttons in order to unify the content of the messages. This would have saved me from forgetting to modify content in certain places.

      Thank you for helping me.

Content aside

  • Status Answered
  • 2 mths agoLast active
  • 6Replies
  • 36Views
  • 2 Following