Forum Discussion

KevinO_Boyle's avatar
KevinO_Boyle
Qrew Cadet
8 years ago

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

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>";
  • 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.
  • JackFretwell's avatar
    JackFretwell
    Qrew Assistant Captain
    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).
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      I have put an App in the Exchange called URL formula for Dummies. It is a starter guide to making URL formula buttons.
    • JackFretwell's avatar
      JackFretwell
      Qrew Assistant Captain
      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.
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      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
  • 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.
  • JackFretwell's avatar
    JackFretwell
    Qrew Assistant Captain
    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.

    : / 
  • JackFretwell's avatar
    JackFretwell
    Qrew Assistant Captain
    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. 
  • 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.