Need to create email button on a form that sends the form fields (or form) to QB User directly.

  • 0
  • 1
  • Question
  • Updated 2 weeks ago
  • Answered
Photo of Corey Ellis

Corey Ellis

  • 172 Points 100 badge 2x thumb

Posted 6 months ago

  • 0
  • 1
Photo of Kevin O'Boyle

Kevin O'Boyle

  • 602 Points 500 badge 2x thumb
You can create a formula - rich text button that references an email icon image. The button can call two nested urls, the first which is an edit record api command that will trigger an email notification of a for
; and the second component is a url redirect
Photo of Corey Ellis

Corey Ellis

  • 172 Points 100 badge 2x thumb
HI and thanks for your reply. Would you be able to share the formula to use to trigger email component and then the url redirect?
Photo of Gil Spigelman

Gil Spigelman

  • 870 Points 500 badge 2x thumb
Corey,
Download the Magic Buttons app and there you'll find a bunch of cool buttons with formula-urls to do what you want.
Photo of Corey Ellis

Corey Ellis

  • 162 Points 100 badge 2x thumb
HI Thanks for your reply. I will look at the magic buttons and see if that can help.
Photo of Gil Spigelman

Gil Spigelman

  • 870 Points 500 badge 2x thumb
Use the button to edit a record, check a box and trigger the email.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,306 Points 50k badge 2x thumb
Corey

Here is an example of a  formula URL button which will change the value of a checkbox and put up a green message for 5 seconds (5000 miliseconds)



var bool NewToggle = not [Toggle field to send email];

var text URL = URLRoot() & "db/" & "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_80=" & $NewToggle;

"javascript:" &
"$.get('" & 
$url & 
"',function(){" &
"$.jGrowl('Email has been sent', {life: 5000, theme: 'jGrowl-green'});" &
"});" &
"void(0);"

Is that what you are trying to do?  Just trigger an email Notification?
 
Photo of Corey Ellis

Corey Ellis

  • 172 Points 100 badge 2x thumb
Hi  Thanks for your reply - I am trying to generate an email directly to a QB user with all the fields from  a form (about 10 fields). I used a URL Formula field and created a button with code: URLRoot() & "db/" & Dbid() & "?a=GenEmailRecord&rid=" & [Record ID]  & "&dfid=29" but then it takes me to page where I have to put in the user I want to send the mail to, then hit a send button. I would like to send a direct email with the form fields to a specific user once the button is hit.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,306 Points 50k badge 2x thumb
If the email address is a field on the record, then you can use my post just above this one to "jiggle" a toggle field (ie a checkbox field) on the record and sent an email Notification to the email address.

If the intended recipient is  not a Quick Base user then be sure to set the Type of email Notification to "Open".
Photo of Corey Ellis

Corey Ellis

  • 172 Points 100 badge 2x thumb
Thanks for your help! where do you specify email recipient in the formula so it knows where to send email? It is to an internal QB User. 
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,306 Points 50k badge 2x thumb
You will need to have a field on the record to use on the Notification.  If it needs to actually be hard coded to a particular user, then it would be a formula email field type with a formula of

"john.smith@gmail.com"
Photo of Corey Ellis

Corey Ellis

  • 172 Points 100 badge 2x thumb
Thanks. I cannot get this to work. The original formula I had works, I just would like to add addtional code, if possible, to send a direct email to a specific QB user. 

Here is the code I used: URLRoot() & "db/" & Dbid() & "?a=GenEmailRecord&rid=" & [Record ID]  & "&dfid=29"

Can I add a mailto code or some other logic to the code I have to email direct to a specific User? The above code adds all the fields and information I need to send via email. I am just trying to eliminate the extra step of having the QB email come up and selecting which user you want to send to and then actually hitting the send button. Thanks for your help. 
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,306 Points 50k badge 2x thumb
OK, I had thought that you wanted to trigger what is called an Email Notification.

If you want to use your alternative method which allows the user to customize the email, then you can add a line lke this

& "&tolist=" & [my email field]

That will populate the "to box" of that Gen email pop up screen.
Photo of Corey Ellis

Corey Ellis

  • 172 Points 100 badge 2x thumb
Hi - Is there a way to auto populate a subject line as well?  I am using your combined formula:

URLRoot() & "db/" & Dbid() & "?a=GenEmailRecord&rid=" & [Record ID]  & "&dfid=32"
& "&tolist=" & [Finance Admin]

Wanted to see if I can add a Default subject line to this formula so the subject line is filled in with a custom subject I choose. 
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,306 Points 50k badge 2x thumb
Not that I know of, perhaps Dan Diebolt knows
Photo of Corey Ellis

Corey Ellis

  • 172 Points 100 badge 2x thumb
Beautiful - That worked. Thanks so much! Is there any logic I can add that will also send to the email I specify or is this limit? This actually works good, but If I  can get  it to just send after populating the "to box" that would be amazing. 

Here is my total code now and it works and I can live with it:
URLRoot() & "db/" & Dbid() & "?a=GenEmailRecord&rid=" & [Record ID]  & "&dfid=29"
& "&tolist=" & [Tenrox Admin Email]

I would like to auto send to the [Tenrox Admin Email] if possible keeping everything the same after populating the "to box". Is there a way to do that? You have been very helpful. Many thanks!!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,306 Points 50k badge 2x thumb
Corey, it sounds like you are not familiar with an automated email Notifications.
https://help.quickbase.com/user-assistance/notification.html

is that what you want after all?  Push a button and the email gets sent automatically?

If so, then you want to set up an email notification based on a checkbox field being changes.,  Then use my earlier suggestion above to make a button to fire the email off.

var bool NewToggle = not [Toggle field to send email];

var text URL = URLRoot() & "db/" & "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_80=" & $NewToggle;

"javascript:" &
"$.get('" & 
$url & 
"',function(){" &
"$.jGrowl('Email has been sent', {life: 5000, theme: 'jGrowl-green'});" &
"});" &
"void(0);"
Photo of Corey Ellis

Corey Ellis

  • 172 Points 100 badge 2x thumb
Thanks Again! I am familiar with the email notifications, but we want it to be transparent to the end user and give them the option to send the email or not. With your help, I created a button which will allow for this. It is part of a workflow and we want end users to be able to choose to send an email request or not. If they choose to send a request via email, I was trying to see if there was a way to fully send to a specific QB user for those requests. What I have now can work, but I was hoping to bypass the actual need to hit the send button in the Gen email pop up screen. If there is a way to do that, I am golden. 

Thanks Again! Very helpful to me and I really appreciate the insight and help you provided. 
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,306 Points 50k badge 2x thumb
Ok, so I'm not sure if your problem is solved yet and I'm still confused by if you want to just fire the email via a Notification, or if you want to pause and allow the user to edit the email body using the GenEmailRecord method.

But if you are happy now them I am happy.
Photo of Corey Ellis

Corey Ellis

  • 172 Points 100 badge 2x thumb
Hi - We don't want to fire an email notification based on field modifications as this would not be transparent to the end user. I want to use the GenEmailRecord method, but want to send directly to a specific user every time (We created a generic account in QB for email purposes). At this point, all I am looking to do is bypass the GenEmailRecord, popup screen where you can edit the body of the email and then hit send. If I put in additional code to just send the email bypassing the need to hit the send button in the GenEmailRecord, that would be great. If not, we can live what we have now and the code you provided works. 

Thanks again.

Corey
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,306 Points 50k badge 2x thumb
If you want the user to hit a button, see a green pop up saying that the email was sent (hence transparent to the user), then use an email Notification.

If you prefer to hand edit the email content and manually press Send, then use the GenEmailRecord method.
Photo of Corey Ellis

Corey Ellis

  • 172 Points 100 badge 2x thumb
Thanks so much. I have the option to do it either way now. I will demo with the team and see what they prefer. Thanks!
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,502 Points 20k badge 2x thumb
>If there is a way to do that, I am golden. 



Lost in Space Episode 44: The Golden Man
Golden Man Requests Help From Jupiter 2 To Battle Alien Frog
https://midnitereviews.com/2015/07/lost-in-space-episode-44-the-golden-man/

Here is a pastie that defines a function youSentEmail() with the following signature
youSentEmail(dbidTable, rid, dfid, toList, subject, msg);
Supply the appropriate parameters and a promise will be returned which when it resolves you can do further processing:
youSentEmail(dbidTable, rid, dfid, toList, subject, msg)
  .then(function() {
    console.log("You Sent Email!");
  });
Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=683

Notes:

(1) The script first grabs the page ?a=GenEmailRecord and extracts the PageToken form the page. The PageToken is needed to successfully submit the page ?a=DoValidateEmailRecord which does the actual email submission. PageTokens are some type of security nonce which are used by QuickBase to prevent CSRF (Cross-Site Request Forgery).

(2) The function youSentEmail can be bound to a button click by any of the standard methods. Likewise the parameters toList, subject, msg can be hardcoded or passed from field values on the record.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,502 Points 20k badge 2x thumb
(3) The received email looks like this: