Forum Discussion

RobinCC's avatar
RobinCC
Qrew Cadet
9 years ago

What is the URL to edit a field, redirect to app homepage, and then display a pop-up message all with one button?

I already have the URL to edit the field and redirect to the app home page. That was easy and it works perfectly. I just need the extra part to also display a pop-up message.

The URL thus far is as follows:
var bool checkedstate = If([Request Access Modification Field for Notification], false,true);

URLRoot() & "db/" & Dbid() & "?a=API_EditRecord"& "&rid="& [Project ID#]& "&_fid_430="& $checkedstate & "&rdr=" & URLEncode(URLRoot() & "db/bgafau47s")


Separately, I got the following javascript to work on its own in a URL button:
"javascript: alert ('Your Request Has Been Sent. ')"


How do I combine the two elements into one button?
Thanks

32 Replies

  • I have never been able to combine redirects with JavaScript. I suspect you would need to do it all in java script, but let's see if anyone answers.

    If you just want want the edit and a pop up message, I can do that.
  • I'm fine with just an edit and a pop-up message.  I was under the impression that a redirect of sorts was always required with URL's like this, but if that is not the case, then yes, I would like to see the edit and pop-up.  Thanks
  • Here is my current best version. This one is setting a checkbox to be checked.

    var text URL = URLRoot() & "db/" & "?act=API_EditRecord&_fid_80=1&rid=" &
    [Record ID#];
     
    "ja ascript:" &
    "$.get('" &  
    $url &  
    "',function(){" &
    "$.jGrowl('This Item has been put on PO CANCEL snooze', {life: 5000, theme:
    'jGrowl-green'});" &
    "});" &
    " oid(0);"

    The 5000 means 5 seconds until it fades away. I like this version as it the same green color as the native QuickBase pop ups.

    Note that when you do these kind of pop ups, the pop-up will show a success message even if the URL formula completely fails. So it's up to you to be sure that there is no possible way that the URL formula will fail.
    • SumedhaWeerasur's avatar
      SumedhaWeerasur
      Qrew Cadet
      Hey Mark, This neat! But for some reason i have having some trouble getting it to work. 

      I created a url button and pasted in your code. The Javascript executes and i see the green message. But the checkbox field i have in fid_24 is not getting toggled. 

      My modified code is below 

      var text URL=URLRoot() & "db/" & "?act=API_EditRecord&_fid_24=1&rid=" & [Entry Number]; 

      "javascript:" & 
      "$.get('" &  
      $url &  
      "',function(){" & 
      "$.jGrowl('This Item has been put on PO CANCEL snooze', {life: 5000, theme: \n'jGrowl-green'});" & 
      "});" & 
      " oid(0);"


      can you spot anything weird with it? 
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      It probably needs an apptoken or else you need to disable app tokens in the Advanced properties for the app.


      The way to test that is to comment out or remove the whole javascript block and replace it with just 

      $URL

      That will run the edit and expose the XML error or success message.

      If you need an app token the formula would look like

      var text URL=URLRoot() & "db/" & "?act=API_EditRecord&_fid_24=1&rid=" & [Entry Number]
      & "&apptoken=xxxxxxxxx";

      The Advanced Properties of the app is where you manage app tokens.  App Tokens are an extra layer of security.   I usually turn them off unless my client has some super sensitive data, such as HIPPA health records

       
    • SumedhaWeerasur's avatar
      SumedhaWeerasur
      Qrew Cadet
      Hmm, this is still not working for me tho. I tried it with an with and without an apptoken. 

      var text URL=URLRoot() & "db/" & "?act=API_EditRecord&_fid_24=1&rid=" & [Entry Number]

      "javascript:" & 
      "$.get('" &  
      $url &  
      "',function(){" & 
      "$.jGrowl('This Item has been put on PO CANCEL snooze', {life: 5000, theme: \n'jGrowl-green'});" & 
      "});" & 
      " oid(0);
  • Got it.  It works great.  Thanks again.  Actually, I really like that the page does not reload every time I click the button. This lets me click the button for multiple records really fast, and the edits are then still happening in the background even though I can't see it.  Of course, to then see the edits, I would have to reload the page, but this way I can reload the page just one time not each time.
  • Yes, I totally agree. Sometimes you do want the page refresh but at other times it just slows down the process way too much so it's great to have that tool in your toolkit of quick base tricks.
  • Hey Mark, would it be possible to have this notification popup while still having the page reload? I have a case where I need the page to reload because certain fields will be shown after the button is clicked, however I think the popup is a good indicator to have in there as well.
  • >I have never been able to combine redirects with JavaScript
    >I don't know how to both refresh and pop up.
    >Sometimes you do want the page refresh but at other times it just slows down the process

    Why not just do it in JavaScript all the time and free your mind from the vagaries of all these special cases and the special handling they require?