0

Dialog behaviour

Hi, I am trying to achieve what I imagine to be, a very simple process but keep hitting a brick wall.

I have a button set up on my form to clear certain fields when pressed (2 date and 2 time fields)

The button works fine but I want to add a dialog with yes/no options, this also works but selecting yes or no gives me the same result.

I have tried if/then and switch but no joy. I have added a seperate yes/no switch which the button can control but I get the same result.

I'm assuming that this is a simple one and I have just missed part of the formula or syntax is incorrect.

This is the current (simple) version which is only addressing one date field:

dialog("⚠️", "Do you wan't to clear all dates?", ["Yes", "No"]);
if "yes" then 'Ship Date' := null end

The yes button works correctly but clicking no also clears the field.

Any advice is greatly appreciated

5replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
    • Bill Thomson
    • Ashtead Good Neighbours
    • Bill_Thomson
    • 11 mths ago
    • Reported - view

    Hi Rob

    i think you have to capture the result of the dialogue function in a variable then test that variable e.g.

    let x:= dialog(etc.;

    if x= "Yes" then ...

    Like
  • let avv:= dialog("⚠️", "Vuoi cancellare tutte le date?", ["Sì", "No"]);
    if avv= "Si" then

    'Ship Date' := "";

    alert("Le date sono state cancellate")

    end

    Like
    • Rob
    • Rob
    • 11 mths ago
    • Reported - view

    Hi Bill & Antonello, Mnay thnaks for responding.

    I had tried that previusly but the result is that clicking yes or no on the dialog has no effect on the field.

    All very confusing, I usually find that after "playing" with the formula for a while; Ninox usually returns the correct result.

    I wonder if it relates to the behaviour of date fields.

    Thanks again for the advice

    Like
    • Bill Thomson
    • Ashtead Good Neighbours
    • Bill_Thomson
    • 11 mths ago
    • Reported - view

    Hi again Rob, 

    There's an error in your code snippet, you have "Yes" in the dialog but "yes" in the next line. They need to be the same. 

    I've checked the following and it does work, just as Antonella's should as well.  If you select "No" today's date is returned. 


    let 'Ship Date' := today();
    let ans := dialog("⚠️", "Do you wan't to clear all dates?", ["Yes", "No"]);
    if ans = "Yes" then 'Ship Date' := null end;
    alert("Ship Date " + format('Ship Date', "DD MMM YYYY"))

    Like
    • Rob
    • Rob
    • 11 mths ago
    • Reported - view

    I can't believe I missed that! Thank you so much for checking and testing. I had been looking at all the more complex elements and completely ignored the formating of my text.

    All now works exactly as expected.

    Thanks again to both of you. Very much appreciated.

    Like
Like Follow
  • 11 mths agoLast active
  • 5Replies
  • 266Views