Forum Discussion

IvanWeiss's avatar
IvanWeiss
Qrew Captain
6 years ago

Combining MailTo with Edit Record API

I have a button I am trying to create which will send an email through Outlook as well as update a date field on the table so I know when the email was created.  I do not think the second call is working.  It looks like a blank change after the email sends.  Not sure if I can combine these two sets of code or not?

var text URLONE = "MailTo:" & [Company - Startup & Demo Request Email] &
"?cc=" & ToText([Project Manager]) &
"&subject=" & URLEncode("Schedule Startup & Demo - ") & [Manufacturer] &
"&body=Please schedule the following request and confirm receipt of this email:" & "%0A%0A" &
"Manufacturer:  " & [Manufacturer] & "%0A" &
"Model:  " & [Model] & "%0A" &
"Serial:  " & [Serial] & "%0A" &
"Roequested Date:  " & [Requested Date] & "%0A" &
"Prject Name:  " & [Project Name] & "%0A" &
"Project Address:  " & [Project Address] & "%0A" &
"Primary Contact:  " & [Primary Contact Full Name] & "%0A" &
"Elite Project Manager:  " & ToText([Project Manager]);


var text URLTWO = URLRoot() &"db/" & Dbid() & "?a=API_EditRecord"
    & "&rid=" & [Record ID#] &
    "&apptoken=c5gchf9bhwx6umbd2ii5zdqtb5x8" &
    "&_fid_26=" & Today() &
    "&rdr=" & URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#];


$URLONE & "&rdr=" & URLEncode($URLTWO)
  • np, just do the steps in the reverse order.

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

    or less confusingly rename your formula variables to reverse their names.


    Note that this will assume that you users do go ahead and sent that Outlook email.  If they get stuck by lightning or abducted by aliens and fail to send, it will will be recorded as sent.


    • IvanWeiss's avatar
      IvanWeiss
      Qrew Captain
      Okay so I need to remove the redirect from Variable 2 right?  I was trying to do that last since after I am done with this I want to refresh the page in display mode so I see that update.

      If I reverse and put the mailto second I am not sure how I can trigger that refresh?

      And yes lol I am hoping my users actually hit send as I dont know what else to do about that.  I think if they get abducted by aliens I do have a bigger issue than that email on my hands :)
    • IvanWeiss's avatar
      IvanWeiss
      Qrew Captain
      As expected when I do that it does work but I get left with a white page and nothing on it.  Can I do a redirect after the mailto?
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      What is your mail client?  Is it some kind of webmail?  Or Outlook installed?
  • I don''t think that there is a way to redirect after the mail to.  I would have to spend some time testing and I have some client deliverables to deliver right now.

    what happens if you delete this part here

    "&rdr=" & URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]
  • Okay so what Quick Base is not a fan of is performing different tasks from the same button click without some extra effort. I have never tried an email like this along with an edit but I have tried an add with an edit. Here is an example of a rich text formula button doing an edit and an add in the same table.
    I combine the 2 commands into 1 URL but wrap both in a single URLEncode. There is a rdr in between the api's  and then another ERLEncode the second api. Both of the URLEncode's end at the end of the var.  Wrapping in URLEncode is the trick. Here is an example of an edit and add working together.

    // Begin button style
    var text bgcolor = "#74489D";
    var text bgcolorm = "#BB8AF7";
    var text txtcolor = "white";
    var text style = "style=\"text-decoration: none; box-shadow: 3px 3px 1px #888888;  background:" & $bgcolor & "; color: " & $txtcolor & "; border-radius: 3px; padding: 5px 8px; display: inline-block;  font-weight: normal;font: 700 24px/1 \"Calibri\", sans-serif; \" onMouseOver=\"this.style.backgroundColor='" & $bgcolorm & "'\";\" onMouseOut=\"this.style.backgroundColor='" & $bgcolor & "'\"; text-align: center; text-shadow:none;";
    // End button style

    var text URL =URLEncode(URLRoot() & "db/" & Dbid()
    & "?a=API_EditRecord&rid=" & [Record ID#]
    & "&_fid_25="&URLEncode("571")
    & "&rdr="
    & URLEncode(URLRoot() & "db/" & Dbid()
    & "?a=API_AddRecord"
    & "&_fid_6="&URLEncode("dog bone")));


    "<a " & $style & " href=\"javascript:" & "$.get('" & $URL & "', function(){" & "location.reload();" &
     "});" & "void(0);\"> TEST </a>"




    I think if you change to and rich text formula and use the following it might work. 


    // Begin button style
    var text bgcolor = "#74489D";
    var text bgcolorm = "#BB8AF7";
    var text txtcolor = "white";
    var text style = "style=\"text-decoration: none; box-shadow: 3px 3px 1px #888888;  background:" & $bgcolor & "; color: " & $txtcolor & "; border-radius: 3px; padding: 5px 8px; display: inline-block;  font-weight: normal;font: 700 24px/1 \"Calibri\", sans-serif; \" onMouseOver=\"this.style.backgroundColor='" & $bgcolorm & "'\";\" onMouseOut=\"this.style.backgroundColor='" & $bgcolor & "'\"; text-align: center; text-shadow:none;";
    // End button style

    var text URL = URLEncode( "MailTo:" & [Company - Startup & Demo Request Email] &
    "?cc=" & ToText([Project Manager]) &
    "&subject=" & URLEncode("Schedule Startup & Demo - ") & [Manufacturer] &
    "&body=Please schedule the following request and confirm receipt of this email:" & "%0A%0A" &
    "Manufacturer:  " & [Manufacturer] & "%0A" &
    "Model:  " & [Model] & "%0A" &
    "Serial:  " & [Serial] & "%0A" &
    "Roequested Date:  " & [Requested Date] & "%0A" &
    "Prject Name:  " & [Project Name] & "%0A" &
    "Project Address:  " & [Project Address] & "%0A" &
    "Primary Contact:  " & [Primary Contact Full Name] & "%0A" &all the email stuff....
    "Elite Project Manager:  " & ToText([Project Manager])
    & "&rdr="
    & URLEncode(URLRoot() &"db/" & Dbid() & "?a=API_EditRecord"
        & "&rid=" & [Record ID#] &
        "&apptoken=c5gchf9bhwx6umbd2ii5zdqtb5x8" &
        "&_fid_26=" & Today() &
        "&rdr=" & URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]));
    "<a " & $style & " href=\"javascript:" & "$.get('" & $URL & "', function(){" & "location.reload();" &
     "});" & "void(0);\"> EMAIL AND EDIT </a>"