Discussions

 View Only
  • 1.  API Edit Record, Mailto, and a rdr or nexturl?

    Posted 09-23-2021 17:30
    Hi everyone,

    I am trying to create a button via rich text field that will process an API call to update a record, open an email via a mailto, and redirect back to the record page I was on in one click.  I understand there is no way to confirm the email was sent, but opening in the browser will be okay by me.  Here is the code I have, which shows a white blank page after running.  How do I continue the rdr back to the url?  You can see I commented out code as it was not working:

    var text baseurl = URLRoot() & "db/"& Dbid();
    var text purchTbl = $baseurl & [_DBID_PURCHASE_ORDERS];
    var text editRecord = "?a=API_EditRecord&apptoken=" & [EliteApptoken] & "&rid=" & [Record ID#];
    var text LABEL = "Executive Approval";
    var text decoration = "text-decoration: none;";
    var text bgColor = "background: #0044cc;";
    var text txtColor = "color: white;";
    var text txtAlign = "text-align: center;";
    var text txtShadow = "text-shadow: none;";
    var text border = "border-radius: 5px;";
    var text padding = "padding: 8px 20px;";
    var text display = "display: inline-block;";
    var text font = "font: normal 700 24px/1 'Calibri', sans-serif;";
    var text styleOptns = List("", $decoration, $bgColor, $txtColor, $txtAlign, $txtShadow, $border, $padding, $display, $font);
    var text mailto = "mailto:" & [Manufacturer - PO Submission Email] & "?subject=Purchase Order&body=Please review the attached Purchase Order and confirm receipt.";

    If([Old PO], "",
    If(IsNull([Executive Review On]) and IsNull([Project Review On]),
    "<span style= 'font-family:Calibri;color:#57a3f0;font-size:14px'><Strong>Requires Executive Approval</Strong><br /></span>",
    "<div><a style='" & $styleOptns & "' class='Vibrant' href='"
    & $baseURL & $editRecord &
    "&_fid_40=" & Today() & "&rdr=" &
    URLEncode($mailto) &
    //URLEncode("&rdr=" &
    //URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]) &
    "'>Submit PO</a></div>"))//)

    ------------------------------
    Ivan Weiss
    ------------------------------


  • 2.  RE: API Edit Record, Mailto, and a rdr or nexturl?

    Posted 09-24-2021 07:06
    I doubt its possible to redirect after the mailto.  You can open that mailto up in a new browser tab though and preserve where the user was in Quickbase on the original tab.

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 3.  RE: API Edit Record, Mailto, and a rdr or nexturl?

    Posted 09-24-2021 08:11
    I think that would work but how would I go about doing that?  Since it is a rich text field there is no "checkbox" to open as a popup.  I am assuming I could insert a target=_blank somewhere but not sure where it would go in this syntax.

    Thanks Mark!

    ------------------------------
    Ivan Weiss
    ------------------------------



  • 4.  RE: API Edit Record, Mailto, and a rdr or nexturl?

    Posted 09-24-2021 08:14
    Nevermind I got it!  I can put it in the very front

    ------------------------------
    Ivan Weiss
    ------------------------------



  • 5.  RE: API Edit Record, Mailto, and a rdr or nexturl?

    Posted 01-27-2022 10:49
    Gotta post that working code bro!  :)

    ------------------------------
    Meredith Moore
    ------------------------------



  • 6.  RE: API Edit Record, Mailto, and a rdr or nexturl?

    Posted 01-30-2022 08:45
    That will cost you!

    var text baseurl = URLRoot() & "db/"& Dbid();
    var text purchTbl = $baseurl & [_DBID_PURCHASE_ORDERS];
    var text editRecord = "?a=API_EditRecord&apptoken=" & [EliteApptoken] & "&rid=" & [Record ID#];
    var text LABEL = "Executive Approval";
    var text decoration = "text-decoration: none;";
    var text bgColor = "background: #0044cc;";
    var text txtColor = "color: white;";
    var text txtAlign = "text-align: center;";
    var text txtShadow = "text-shadow: none;";
    var text border = "border-radius: 5px;";
    var text padding = "padding: 8px 20px;";
    var text display = "display: inline-block;";
    var text font = "font: normal 700 24px/1 'Calibri', sans-serif;";
    var text styleOptns = List("", $decoration, $bgColor, $txtColor, $txtAlign, $txtShadow, $border, $padding, $display, $font);
    var text mailto = "mailto:" & [Manufacturer - PO Submission Email] &
    If([CC PO Submission Email] != "", "?cc=" & [CC PO Submission Email],"") &
    "?subject=Purchase Order&body=Please review the attached Purchase Order and confirm receipt.";

    If([Old PO], "",
    If(IsNull([Executive Review On]) and IsNull([Project Review On]),
    "<span style= 'font-family:Calibri;color:#57a3f0;font-size:14px'><Strong>Requires Executive Approval</Strong><br /></span>",
    "<div><a target='_blank' style='" & $styleOptns & "' class='Vibrant' href='"
    & $baseURL & $editRecord &
    "&_fid_40=" & Today() & "&rdr=" &
    URLEncode($mailto) &
    //URLEncode("&rdr=" &
    //URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]) &
    "'>Submit PO</a></div>"))//)

    ------------------------------
    Ivan Weiss
    ------------------------------



  • 7.  RE: API Edit Record, Mailto, and a rdr or nexturl?

    Posted 02-07-2023 12:10

    Hi Ivan,

    I'm currently looking to achieve the same goal as you. When the button is pressed:
    1. Edit the current record and update a certain field with the current date
    2. Open the Send to Outlook feature in outlook
    3. Return the user back to the record after the change in #1

    I was not able to decipher which part of your code gets the user back to the record they were on. Can you please help me understand your code so I can replicate it and get it working on my end?

    Thank you for your time.



    ------------------------------
    Fraidy Jacoby
    ------------------------------



  • 8.  RE: API Edit Record, Mailto, and a rdr or nexturl?

    Posted 02-07-2023 17:06
    To make this easier to work with all of the early on code is just setting the variables with portions of the button functionality and styling so that later on I can make its such simpler.  This is the section of code that actually executes the work.  It obviously references those variables earlier on.

    href='"
    & $baseURL & $editRecord &
    "&_fid_40=" & Today() & "&rdr=" &
    URLEncode($mailto) &
    //URLEncode("&rdr=" &
    //URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]) &
    "'>Submit PO</a></div>"))//)

    To try to step through it:

    The baseURL is my app URL
    Edit Records performs the edit
    It processes the mailto.

    I honestly do not remember why I commented out those two bottom sections (shame on me for not documenting where I left off).  I think the button just stays on the current record so I never got it working with a refresh.

    ------------------------------
    Ivan Weiss
    ------------------------------



  • 9.  RE: API Edit Record, Mailto, and a rdr or nexturl?

    Posted 02-07-2023 17:20
    @Fraidy Jacoby
    I know it's hard to prove a negative but I'm pretty sure it's not possible to do what you're asking. Quickbase can do quite a large number of successive actions in a URL button but that assumes that at each step in the action you're running an API and then the last step typically is to land user on a record or a report for a page. 

    But in this case once you go to an external URL or open up some kind of mailto: command,  then that is going to be the end of the successive actions.  ​

    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------