Best way to trigger notification email

  • 0
  • 1
  • Question
  • Updated 3 months ago
  • Answered
I have an application that has a parent child table relationship.  After the user sets up the Shipment (Parent) they will add Items (Child) to the shipment.  The amount of items can be different every time a Shipment is created.  When the user is done adding items to the shipment I want to send an email notification.  My question is what is the best way to trigger the notification when the user is finished adding items?  I do not want to send a notification every time an item is added and sending a notification when the Shipment is set up does not actually mean the shipment is ready for processing as the user needs to still add Items to the shipment.  Any suggestions is much appreciated.
Photo of Brian

Brian

  • 120 Points 100 badge 2x thumb

Posted 3 months ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 57,468 Points 50k badge 2x thumb
I suggest making a formula URL button to populate a field with the current date/time. to trigger the Notification based on that field changing.  The button would be on the parent record.  I can help you with the formula if you need that help.
Photo of Brian

Brian

  • 120 Points 100 badge 2x thumb
Ok, so how would that work?  The user clicks a button, the field is updated, and because the field is modified, the notification is sent?
Photo of Brian

Brian

  • 120 Points 100 badge 2x thumb
Yes can you send the formula to do that?  Thanks
Photo of Brian

Brian

  • 120 Points 100 badge 2x thumb
I have a checkbox field named Shipment_Complete.  Can that be used as the modified field?  If not the current date and time field would be fine.  What type of field would that be?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 57,468 Points 50k badge 2x thumb
var text URL = urlroot() & "db/" & dbid() & "?act=API_EditRecord"
& "&apptoken=xxxxxxxxx"
& "&_fid_xx=" ToText(now());


"javascript:" &
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});" 
& "void(0);"

// note, if you have application tokens enabled in the Advanced Properties setting for the app, you will need to include that apptoken line

Replace xx with the field Id of a date time field that you will use on the form to show the users when the notification has been sent.
Photo of Brian

Brian

  • 120 Points 100 badge 2x thumb
Ok so I removed the apptoken line since I am not using apptokens.

I created a "EmailSent" Date/time field.  ID = 57

I also created "EmailButton" Formula URL field where I placed the code and got the following:

0


When saving I get the following error:

Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 57,468 Points 50k badge 2x thumb
fix this line to be

& "&_fid_57=" & ToText(now());

Photo of Brian

Brian

  • 120 Points 100 badge 2x thumb
Sorry to be so needy...first time doing this.  Code seems fixed.

I have the button (EmailButton) with the Code behind it and the EmailSent (FieldID=57) Date time field.  

I have created a notification as follows:
Notification When: a shipment is Modified and "Any of the following fields change with "EmailSent" checked.

I click the button and nothing seemed to happen.

EmailSent field still blank after clicking button.
(Edited)
I would have a field for the user to mark as "Complete", when they know that there are no more items to be added or edited and it is final. Then have your email go out when a record is modified and that field is modified and after it is modified, it is "Complete".
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 57,468 Points 50k badge 2x thumb
The API is failing but that javascript is hiding the error message.

Copy the field as a test and just have this

var text URL = urlroot() & "db/" & dbid() & "?act=API_EditRecord"
& "&apptoken=xxxxxxxxx"
& "&_fid_57=" & ToText(now());

$URL


Run that button and it will expose the error message.  I suspect that you have application tokens enabled.


Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 57,468 Points 50k badge 2x thumb
sorry, i meant this

var text URL = urlroot() & "db/" & dbid() & "?act=API_EditRecord"

& "&_fid_57=" & ToText(now());

$URL
Photo of Brian

Brian

  • 120 Points 100 badge 2x thumb
Ok here is what I received:


Require Application tokens check box under Security Options is unchecked.
(Edited)
Photo of Brian

Brian

  • 120 Points 100 badge 2x thumb
Yes I ran it without the apptoken line.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 57,468 Points 50k badge 2x thumb
what happened when you ran it without the javascript, like i suggested.
Photo of Brian

Brian

  • 120 Points 100 badge 2x thumb
Same error:

Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 57,468 Points 50k badge 2x thumb
OK, yes I left out the most important part of the formula, which record to edit!

var text URL = urlroot() & "db/" & dbid() & "?act=API_EditRecord"
& "&rid=" & [Record ID#]
& "&_fid_xx=" & ToText(now());


"javascript:" &
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});" 
& "void(0);"
Photo of Brian

Brian

  • 120 Points 100 badge 2x thumb
Still nothing happening.  EmailSent date/time field still blank. 

Error with no Java:  




Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 57,468 Points 50k badge 2x thumb
That as a success message. The original button will now work if you add in that extra line like I suggested.
Photo of Brian

Brian

  • 120 Points 100 badge 2x thumb
Success!!!!!  Thanks so much for the help.