A bot that should be triggered only when a condition exists, runs all the time.

I have a non-virtual column called "Gel Pack" in the table AWB.  It's an Enum column with 2 values: "Yes" and "No".

AppSheet 1.png

 

I have a bot that must be fired with the "Add" event and when the value of the column "Gel Pack" is "Yes" (if the Gel Pack column is "No", the bot must not be fired).

AppSheet 2.png

If I click on "Test",  it shows that the Event condition is "False" when the Gel Pack column is "No", and it's "True" when the Gel Pack column is "Yes".

AppSheet 3.png

The app is in Prototype mode.

Why is it triggered all the time?

Solved Solved
0 29 168
1 ACCEPTED SOLUTION

OK. All of these explanations are useful. Thank you.

Going back to the bot, I found the problem. I tried this:
1- I configured the bot without the condition ([Gel Pack]="Yes").
2- I wrote an IF statement in my script to run the function if [Gel Pack]= "Yes", otherwise, to not run the function.

To my surprise, a due date was still entered into the Google Sheet. That means something was entering the date. I looked at the "Expiration Date and Time" column and found that there was a "Now()" expression in the "Initial Value". The logic and the bot were always fine. The "Now()" expression was the cause of the problem.

I'm sorry. I know you spent time on this. I hope this post can be helpful to someone with a similar issue.

View solution in original post

29 REPLIES 29

When you say 'triggered all the time' do you mean it shows up in the audit log and the automation log? If that is what you mean then you should also note that the event condition in the log with also show true or false and the rest of the bot will not execute if false.

With  "triggered all the time" I mean it executes always, no matter if the condition is "True" or "False".

The last screenshot of my original post is taken from the "Bot Test" , not from the "Bot Monitor".

This is what I see from the Monitor.

 

AppSheet 4.png

So the monitor logs that the bot was initiated and that the bot completed vs failed. So does it actually complete your Process which appears to be a script? Or are you asking why does it execute at all since the app is in prototype mode?

This is what I want:
The bot must be fired with "Adds Only" and when the column "Gel Pack" is "Yes".  If the Gel Pack column is "No", the bot must not be fired. This was mentioned in the original post.

If I have set "Adds" and [Gel Pack]="Yes", I expect the bot to execute only when this 2 conditions exists, but this is not happening.  The bot runs for all "Adds", no matter if the column [Gel Pack] is "Yes" or "No".

What am I missing?

The function of the bot is to execute an Apps Script.  This script must be executed only when 2 conditions exists: when there is and "Add" and when the  [Gel Pack]="Yes".

Rigth now, the script is executed with every "Add", regardless of whether the [Gel Pack] is "Yes" or "No".

I hope this clarify the scenario.

Sorry, I posted a long winded reply prior to seeing your latest response. That should not happen. So then we need to take a look at some of your other items.

What other items do you have to look at?

On a side note, have you tried a True/False column (Appsheet calls this a Yes/No) column instead of using Enum with Yes and No choices.

I haven't tried it because I had some issues with it in another app, but I can try an let you  know.

Your screenshot of the Enum column doesn't show what the Basetype is. Can you show that? I am wondering if there is a mismatch on the "Yes" which will be interpreted as text, so if the Enum YES/NO basetype is not text, then that could be a problem.

The Base type is "Text".

AppSheet 5.png

Also, I have an Initial Value of "No".

AppSheet 6.png

Just thought of something to try. Uncheck the 'Auto-complete other values' in your column setting. I seem to recall that this setting has presented some problems for me in the past.

I unchecked the "Autocomplete other values", but nothing changes.

So on occasion with Appsheet I have found that recreating something has helped because something gets turned around in Appsheet's internal memory for the lack of a better term. So I might recommend recreating the bot only and deleting the existing bot. If you are still facing the problem after that I'm afraid I'm at my witts end and don't know that I have anything else productive to add to the conversation other than contacting Appsheet support.

Just for your knowledge I added an extra column to an application of mine as an enum with Yes and No as choices and then I just created a simple bot that sends an email only if that column value is "Yes". I tested a single entry with "Yes" and it executed the send email, then I tested a "No" and it did not send the email.

I agree with you.  I have deleted expressions that are correct but for some reason, Appsheets warns they have an error.  Then I re written the same expressions and they work.  

I'll try it.

Thanks Markus,

I changed the column type from Enum to Yes/No.

AppSheet 7.png

In the bot, I changed the condition to [Gel Pack]=Y with no success.  Also, I tried [Gel Pack]="TRUE" because that's the value that the app writes in the Google Sheet (see below), but nothing changes.

The script set an expiration time.

AppSheet 8.png

You can see in the Google Sheet that the first rows are empty in the Expiration Date Time column. That is because I deleted them.
All other rows that have a "No" value or a FALSE" value in the Gel Pack column shows and Expiration Date Time. These cells must be empty with Gel Pack set to "No" and must show an expiration time when Gel Pack has the value of Yes (TRUE).

When using a Yes/No column type your evaluation needs to be just [Gel Pack] for true evaluation or NOT([Gel Pack]) for false evaluation. Or [Gel Pack] = TRUE for true or [Gel Pack] = FALSE for false.

Ok.  Thanks.

To explain a little, a Yes/No column type is a boolean type, not text. So it literally passes a TRUE or FALSE value therefore when wrapping it into quotation marks your are changing it to a text value which again will create problems during the condition check. I realize that Appsheet just flags these as Y or N when you see the value in a detail view, but that is Appsheet's way rather than displaying TRUE or FALSE in a detail view.

Maybe that's the reason I had issues some time ago in another app.

I'm taking note of it.

Thank you,

Yes/No columns are useful for lots of things honestly because an IF() formula in Appsheet simply becomes IF([YourYesNoColumn], "Whatever for true", "Whatever for false"). The only other thing to account for is an empty value which is still possible, but that is why you need to make it a required column and/or configure an initial (default) value.

OK. All of these explanations are useful. Thank you.

Going back to the bot, I found the problem. I tried this:
1- I configured the bot without the condition ([Gel Pack]="Yes").
2- I wrote an IF statement in my script to run the function if [Gel Pack]= "Yes", otherwise, to not run the function.

To my surprise, a due date was still entered into the Google Sheet. That means something was entering the date. I looked at the "Expiration Date and Time" column and found that there was a "Now()" expression in the "Initial Value". The logic and the bot were always fine. The "Now()" expression was the cause of the problem.

I'm sorry. I know you spent time on this. I hope this post can be helpful to someone with a similar issue.

Interesting. Was the [Expiration Date and Time] column part of your process on whether or not to execute the script then? On the note about the NOW() function having been registered in the DateTime column, pay particular attention to that since NOW() will be automatically set in the initial value setting if Appsheet picks up that it is a DateTime column. Also, if you happen to regenerate your table due to a change in the spreadsheet columns or similar, Appsheet will put the TODAY() function into Date columns and NOW() function into DateTime columns even if you previously deleted those functions.

I'm taking note on your comments about the NOW() function.

The answer to your question about the[Expiration Date and Time] column is "No". It was not supposed to have any formula or Initial Value because this value is set by the script only.

[Gel Pack[]="Yes" means there is a due date for that row. [Gel Pack]="No" means there is no due date for that row. The bot determines if the script must be executed. If the condition [Gel Pack[]="Yes" is met, then the bot executes the script, otherwise, not. When executed, the script calculates the due date and write it into the Google Sheet.

I didn't know that the NOW() expression was in the initial value of the [Expiration DateTime] column.
I had to write it by mistake at some point. I did not realize that.

I don't understand.
Your screenshot from the Monitor clearly shows that the selected run has
"Gel Pack" :"Yes" ?

The bot will just run every time you add an entry but since you opened the 'Test' button, this will always show TRUE because it meets the condition of your event.

Yes you're right.  The bot will run with every "Add".

The bot must execute an Apps Script only when 2 conditions are met: when there is and "Add" and when the  [Gel Pack]="Yes".

Rigth now, the script is executed with every "Add", regardless of whether the [Gel Pack] is "Yes" or "No".

Top Labels in this Space