Can I use a formula URL button to create an email using an email client and redirect to the initial report?

  • 0
  • 2
  • Question
  • Updated 2 weeks ago
  • Answered
  • (Edited)
I'm trying to make it easier for my CRM users to research a lead and email a lead so I'm providing URL buttons to enable a google search or a mailto: link.  I'm also trying to track the activity to provide a report to their managers so I need to 1) edit the record, 2) open the email and then 3) redirect back to the original report.  I'm struggling to get the third re-direct to work. 

Code is below

var text weblink = "http://www.website.com";

var number NewToggleValue = If ([Email toggle]=true,0,1);

var text URLONE = URLRoot() & "db/" & Dbid()
& "?act=API_EditRecord&key=" & [Record ID#]
& "&_fid_419=$NewToggleValue"&"&apptoken=aaaaaaaaaaaaaaaaaaaaaaaaaa";

var text URLTWO = "mailto:"&[email address]&";"&[Sales Rep for Leads - Email Address (P)]&";"&[Sales Rep for Leads - Email Address (S)]&"?subject=Your inquiry about ..." &"&body=Hello,%0A%0AThank you for your interest in ...  I’m ... – the sales representative in your area.  My contact details are below.   If there is anything I can do to help with your project, please don’t hestitate to contact me.   %0A%0AThank you.  %0A–"&"{insert name here}"&"%0A"&"{and email here}"&"%0A... You may personalize the message by modifying this text.%0A"&"%0APlease click the link below to learn more: %0A" &$weblink;

var text URLTHREE = URLRoot() & "db/" & Dbid() & "?a=q&qid=153";

"<a href="& $URLONE & "&rdr="& URLEncode($URLTWO) &URLEncode("&rdr="& URLEncode($URLTHREE))&"'><img   src=\"https://images.quickbase.com/si/32/016-email_0.png\"></a>";
Photo of Kevin O'Boyle

Kevin O'Boyle

  • 602 Points 500 badge 2x thumb

Posted 1 year ago

  • 0
  • 2
Photo of Avi Sikenpore

Avi Sikenpore

  • 532 Points 500 badge 2x thumb
Kevin,

Your URLTWO is not actually a URL but a hyperlink to open outlook/mail client. As such quickbase does not know what happens at URLTWO. Without having a finish line for URLTWO it cannot redirect to URLTHREE.

One alternative is to swap URLTWO & THREE.

That way it will edit record , reopen record and open outlook mail.
Photo of Kevin O'Boyle

Kevin O'Boyle

  • 602 Points 500 badge 2x thumb
Yep - that’s it. Thanks brother.
Photo of Jack Fretwell

Jack Fretwell

  • 484 Points 250 badge 2x thumb
Hiya, got a similar issues, what does this bit of code mean "?a=q&qid=153"?  To me it's action = query and query ID = 153, but what is this query?  (If I'm reading the code right).
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,486 Points 50k badge 2x thumb
It means to run report number 153
Photo of Jack Fretwell

Jack Fretwell

  • 484 Points 250 badge 2x thumb
Hiya, I had a look at this last week and didn't really find anything that matches this issue, I'm also using the magic buttons app which has helped a bit.
The issue I'm seeing is when the command for the email is run it plonks the mailto command in the URL which then shows a blank page.  I can't seem to the mailto command without impacting the URL, which is a tad annoying.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,486 Points 50k badge 2x thumb
Can you post your current code.?

I think it might work if you put the mail to command is the last step in the URL formula and also send that checkbox to open a new window
Photo of Jack Fretwell

Jack Fretwell

  • 484 Points 250 badge 2x thumb
This is what I have at the moment.

var text URLONE = URLRoot() & "db/" & [_DBID_ACTIVITIES] 
& "?a=API_AddRecord&_fid_148=" & URLEncode ([Record ID#])
& "&_fid_157=" & [Related Company] 
& "&_fid_7=Email Sent";

var text URLTWO = URLRoot() & "db/" & [_DBID_CONTACTS] & "?a=dr&rid=" & URLEncode([Record ID#]);

var text URLTHREE = "mailto:"& URLEncode([Email]);

$URLONE 
& "&rdr=" & URLEncode($URLTWO) 
& URLEncode("&rdr=" & URLEncode($URLTHREE))

I'm not keen on opening a new page as it will get messy for the users.
If I run $URLONE & & $URLTWO I update the activities and end up where I want to be.

Once I add $URLTHREE something like:

"&rdr=mailto%3customername%2540company.ac.uk"

gets appended to the URL which then shows a blank page. 

When I did try it with new page it shows the activities but the main page goes blank because of the mailto getting into the URL.  


Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,486 Points 50k badge 2x thumb
I don't know if a solution to your situation.  Essentially you need to do two things at the same time, which is to redisplay the record and also to open a new page.

what happens when you do this

$URLONE 
& "&rdr=" & URLEncode($URLThree)

ie omit the URLTWO step.



 


Photo of Jack Fretwell

Jack Fretwell

  • 484 Points 250 badge 2x thumb
Yes, I get an even longer URL.  This shows the URL from the first and third steps... And it shows a blank page as I suspect the MailTo gets in the way. 

QBCOMPANY.quickbase.com/db/bn4dxunyy?a=API_AddRecord&_fid_148=9780&_fid_157=16726&_fid_7=Email%20Sent&_fid_142=11-05-2018%2001:52%20PM&apptoken=XXXXXXXXXXXXXXXXXXXX&rdr=mailto%3NAME%2540COMPANY.co.uk
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,572 Points 20k badge 2x thumb
Try using the IOL Technique with this button formula and module.js:

Paste Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=686

Notes:

(1) I did not test this. Any scenario using an <iframe> and/or the mailto protocol needs to be tested as there may be different behaviors between browsers and the user's registered handler for the mailto protocol.

(2) To prevent the mailto protocl opening an empty tab/window it is opened instead in a hidden <iframe>. Very clever if you ask me.

(3) The three asynchronous tasks (1) ?act=API_AddRecord, (2) ?a=dr and (3) mailto: are arranged in the most likely sequence to have them complete one after the other. But the process is not perfect as the mailto process cannot be monitored.
Photo of Jack Fretwell

Jack Fretwell

  • 484 Points 250 badge 2x thumb
Thanks, I'll give that a go, my last try of trying to get this to work was by adding 

"javascript:" &
"location.reload(true);" &
"$.get('" & 
$URLONE
&"&rdr=" & URLEncode($URLTWO) &
URLEncode("&rdr=" & URLEncode($URLTHREE)) &
&"
"');" &
"void(0);"

This ran URLONE and URLTWO but no email popped up for ULRTHREE.

: / 
Photo of Jack Fretwell

Jack Fretwell

  • 484 Points 250 badge 2x thumb
Wow!!!! worked first time!!!! Dan, you're a star.  Do you mind us using this code? Can't thank you enough, been stuck on this for a couple of days. 
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,572 Points 20k badge 2x thumb
Knock yourself out. Just remember to put my ironclad copyright notice in the bottom of the code or I will have my team hunt you down.
All rights reserved. The code in this page is copyright by Dan Diebolt and may not be used without including my phone number (773-312-8131) and email address (dandiebolt@yahoo.com) in the footer of where you may want to use it.

Photo of Jack Fretwell

Jack Fretwell

  • 484 Points 250 badge 2x thumb
Thank you and will do : )