Form saved event works erratically

I use the Form Saved event to send a message via Whatsapp with the details of the amount paid and the balance of a fee. The problem is that sometimes it sends it correctly other times it doesn't. I deduce that it is because the event does not actually wait for the save to finish, but rather fires when the save button is pressed. In any case, the columns that I use are the amount paid, which is filled in by the client, or left with the Init Value and the Balance, which is calculated by subtracting the amount minus the amount paid. Those data are already in the Form.

 

I need help understanding what is happening and how to fix it.

I attach an image of the message sent, immediately accepting the event confirmation box, and another one sent after saving the data with a Display Overlay Button of the same action.

 

WhatsApp Image 2022-02-19 at 19.11.06.jpeg

 

@Aleksi_Alkio 

@Steve 

 

0 20 432
20 REPLIES 20

You can base your action on the data change instead of button press, that is you could have two separate actions. The button action will save the form, and another action will send the message based on addition of a new row or the update of the row columns. 

Actually the idea is that automatically when saving, it asks the user if he wants to send the receipt by whatsapp, anyway, there is a button to resend it later. But not doing it at save time can make the user forget to send it later.
Anyway, my question points to how the appsheet sequence works, if both actions (Save and OpenUrl) are triggered in parallel when saving, or is it a sequence. When the Form "Saved" event is called, I understand that the OpenUrl action is fired after having finished saving. In addition, there are no child records, so the information already calculated should be sent without problems.

The second action should launch automatically based on data change, and would not require further user intervention. 

Currently when the user saves a form you have an action based on this save. This action will ask the user if he would like to send the receipt AND it will trigger sending the receipt. 

Instead, this is the proposed scenario:

  1. Add a new column to your table. Let's name it "sendFlag" with an initial value of 0. 

  2. Create two actions: "setFlag" which will change the value of "sendFlag" to 1, and another action "resetFlag", which will change it to 0. 

  3. The user saves the form, sees the question and answers YES. The form save action here will NOT send the whatsapp msg, instead, it will only launch the "setFlag" action. If the answer is NO, the "resetFlag" action should be launched  So far no msg has been sent, and the save action terminates here. 

  4. You create a separate action for a row of your table to send a WhatsApp msg with the contents of this row. Let's name it: sendWhatsApp. 

  5. You add a new bot that will monitor the data change (Adds and Updates) of the rows of your table, on the condition that [sendFlag] = 1. When there's a data change to any row AND the value of "sendFlag", the bot should fire the newly-created sendWhatsApp action for the corresponding row.

 

I'm trying to implement your solution, but I'm running into some obstacles:
1. I can not assign the ResetFlag option, since Send Confirmation does not have that option (This is not a problem because it was already 0 as initial value)
2. The bot that monitors the SendFlag change does not support an OpenURL action. Although it is created, it does not appear in the Run a data action list. If I want to Create New action, there is no option: "External: go to a website"

What I can be doing wrong?
1. Added SendFlag column
2. Create both SetFlag and Reset Flag actions.
3. I assigned SetFlag to the FormSaved event.
4. Create the action (I actually copied the OpenURL action from the system)
5. I added the bot that monitors SendFlag but I can't assign the OpenURL action to it and I understand that next I should also fire the ResetFlag action, so that it returns to 0.

  1. Upon saving the form you can launch a grouped action containing the following two actions:
    1. "resetFlag", that will execute anyway setting the sendFlag to 0, regardless of its current value. 
    2. "setFlag", this action will require user confirmation and will set sendFlag to 1 only upon confirmation by user. 

  2. You are right not all action options are available form the bot. Therefore:
    1. Create a separate action from Behavior, let's name it "openURL", and assigned to the desired table, with Do this - External: Go to a website.
    2. Create an additional action, named: "launchOpenURL", assign it to the same table, and:
      • Do this - Data: execute an action on a set of rows
      • Referenced table: the same table
      • Referenced rows: LIST([_THISROW])
      • Referenced action: openURL

  3. In your bot, you'll now be able to find the action "launchOpenURL", which should trigger upon adding or updating a row in your table. 

Thanks for your answer, but it didn't work.
I attach images: In the bahavior section the action accepts OpenURL, but when selecting it in the bot, the referenced action disappears.
To understand what was not working, I added a second ResetFlag action to the bot, to see if the bot passed by, and yes, it sets the flag to 1 and then sets it to 0, but in between it never opens the URL.

 

 

Captura de pantalla 2022-02-25 143901.png

 

Captura de pantalla 2022-02-25 143956.png

 

In the bot you will not find openURL, you should instead add launchOpenURL. I tested it successfully. 

By the way, I understand that your URL is what you use to send a Whatsapp msg, like: https://wa.me/number/?text=someText

Otherwise, if your URL points to a viewable webpage for example, then yes the view won't open when launched by a bot. 

Exactly, this is the expression I use:

 

HYPERLINK("https://api.whatsapp.com/send?phone=549"&
[Cliente Id].[Formatear Whatsapp]&
"&text="&

 

"*------------ Recibo Cuota Nยบ "&[Cuota Nยบ]&" ------------*%0A%0A"&
"Buenos dรญas "&[Cliente Id].[NyA]&" te envio el comprobante de la cuota:%0A%0A"&

"*Fecha:* "&TEXT(TODAY(),"dd mmm yyyy")&"%0A"&
"*Vencimiento:* "&TEXT([Fecha de Vencimiento],"dd mmm yyyy")&"%0A"&
"*Importe Cuota:* "&TEXT([Importe])&"%0A"&
"*Punitorios:* "&TEXT([Punitorios])&"%0A"&
"*Abonado.:* "&TEXT([Importe abonado])&"%0A"&
"*Saldo Cuota:* "&TEXT([Saldo])&"%0A"&

&"%0A%0A"&

"-----------------------------------------------------------%0A"
&"แดฐแต‰หขแตƒสณสณแต’หกหกแตƒแตˆแต’ แต–แต’สณ แต—แตƒหกแตโฟแต‰แต—แตƒแต–แต–หข แถœแต’แต แตƒสณ"

In the bot I select the action called: "Enviar Recibo de Cuota x Whatsapp" which would be the one you call: "launchOpenURL", which is configured like this:
Do this - Data: execute an action on a set of rows
Referenced table: the same table
Referenced rows: LIST([_THISROW])
Referenced action: openURL. In the bot, this action is not seen in the second image

 

Captura de pantalla 2022-02-25 145644.png

 

You are on the right track. Just put the same action "Enviar Recibo de Cuota x Whatsapp" in the Referenced Action field below. You will find it. 

There is something I can't understand. The panel on the right is the detail of the selected action. If the referenced action is the same action, it calls itself. Anyway, I did the test and it kept saving, until I killed it, and it never reached the ResetFlag action, which tells me that it got stuck inside that action.

 

Captura de pantalla 2022-02-25 145644.png

 

One:

Capture dโ€™eฬcran 2022-02-25 aฬ€ 20.00.29.png

Two:

Capture dโ€™eฬcran 2022-02-25 aฬ€ 20.00.45.png

Three:

Capture dโ€™eฬcran 2022-02-25 aฬ€ 20.01.51.png

I can't get it to work.
I configured Display Overlay for the New Action, and if I run it from the button it opens the Whatsapp app and sends the message, but from the bot it doesn't do anything. I thank you and apologize for so much inconvenience. I attach images of the actions to see if you see what is wrong.

Captura de pantalla 2022-02-25 170618.png

 

Captura de pantalla 2022-02-25 170543.png

 

Captura de pantalla 2022-02-25 170514.png

 

Captura de pantalla 2022-02-25 170000.png

 

No problem my friend ๐Ÿ™‚ 

Would you please show the trigger part of your bot?

The bot works, because if I add another step after New Action and assign ResetFlag to it, the bot sets the flag back to 0, which means that it was executed.

 

 

TalkNet_TechnoS_0-1645841483861.png

 

The last I can think of:

1. Try to remove the condition. I donโ€™t think it is needed here. Put it inside the action that contains the URL. 

2. Try to insert a step that will send an email to your app creator email. 

3. Check the log in the bot monitor and see if it gives any clues. 

Iโ€™m sorry ๐Ÿ˜ž maybe others can help. 

The problem is undoubtedly in the OpenUrl, as it is triggered by the bot. since the same action triggered by the bot, when triggered by hand with the button, works fine, and any other action triggered by the bot also works.
What surprises me is that you told me that you tried it successfully. Could you share your test to compare?

Give us your column description, pls.

//I think, that you are use fields, calculated outside AppSheets ๐Ÿ™‚

If you mean calculated fields in the spreadsheet, this is not the case. Everything is calculated in appsheet. What there is, and it has brought me several inconveniences is that the Paid Amount field has an Initial Value calculated according to several conditions, to avoid the user having to write it by hand in most cases, so if pay the total amount simply press save. Apparently, if no one writes, although the value is saved, it is not taken into account in the calculations, nor does it fire the ChangeTimeStamp event (although the value with respect to the saved changes) and I suspect that is why it does not update that value in the WhatsApp message, which is nothing more than a url concatenated with all the values within the message.

Top Labels in this Space