Discussions

 View Only
Expand all | Collapse all

URL formula to edit a record and ""refresh the page

Archive User

Archive User11-29-2014 22:38

  • 1.  URL formula to edit a record and ""refresh the page

    Posted 03-07-2014 15:50

    I regularly use little API URL formula buttons like this one.

    var text $CopyStatustoPreviousStatus = blah blah blah ......;

    $CopyStatustoPreviousStatus
    & "&rdr=" & URLEncode($ReDisplayReport)

    That works well when I have a button dedicated to either refreshing the record I am sitting on or refreshing a particular report.


    I also use this great technique a lot to not refresh the report (so the user does not lose their place in the report or does not lose their Dynamic filter selections.

    var text URL= blah blah blah ....;

    "javascript:" &
    "$.get('" &
    $URL &
    "',function(){" &
    "$.jGrowl('email Triggered to Prospect', {life: 5000});" &
    "});"
    &
    "void(0);"

    But I would love to know how to make a button which will do some blah blah blah stuff and then refresh the screen - that way I could have the same button be used on any report and any record. Ideally it would reload the screen and preserve the user's Dynamic filter selections if they were on a report.


    If there a way to modify the code above to incorprate this concept
    &"javascript:location.reload(true);"

    and not do the growl pop up. ie I'm looking for a button to be able to execute a URL formula which would say edit a record and then refresh whatever screen the user is on. In that situation with a refresh, typically the user's feedback that the button click "took" will be that the report refreshed or the record refreshed, so we don't need or want that jgrowl pop up.




  • 2.  RE: URL formula to edit a record and ""refresh the page

    Posted 03-07-2014 23:44
    No problem. (channeling you here) =)

    Basically - you want to replace this line:

    "$.jGrowl('email Triggered to Prospect', {life: 5000});" &


    with

    "location.reload(true);" &


    From the jQuery API documentation for $.get: https://api.jquery.com/jQuery.get/

    The function being defined is the success function - that is executed if the request succeeds.

    So instead of executing the Growl call in the success function, you execute the page refresh call.

    I tested this on a test app, and it works even on reports with dynamic filters set.

    Let me know if this works for you.



    The formula URL would look something this (I used an EditRecord in my test as an example):

    var text URL= URLRoot() & "db/" & [_DBID_TABLE_1] & "?act=API_EditRecord"

    & "&rid=" & URLEncode ([Record ID#])

    & "&_fid_7=" & URLEncode ([Status])

    & "&apptoken=" & "XXXX";

    "javascript:" &

    "$.get('" &

    $URL &

    "',function(){" &

    "location.reload(true);" &

    "});"

    & "void(0);


  • 3.  RE: URL formula to edit a record and ""refresh the page

    Posted 12-28-2018 17:07
    This is great!  I think I would like the growl notification in addition to the refresh, but I can't seem to get them both to work at the same time. Is that possible?


  • 4.  RE: URL formula to edit a record and ""refresh the page

    Posted 12-28-2018 17:08
    As far as I know you can refresh the page or jgrowl.  Not both.


  • 5.  RE: URL formula to edit a record and ""refresh the page

    Posted 12-28-2018 17:10
    Still awesome!


  • 6.  RE: URL formula to edit a record and ""refresh the page

    Posted 03-23-2019 00:14
    I do both frequently.  Here's my code:

    var text action = URLRoot() & "db/" & Dbid() & "?a=API_editRecord&rid=" & [Record ID#] & "&_fid_=1;
    var text url = "javascript:" & 
    "$.get('" & $action & "',function(){" & 
    "$.jGrowl('Growl Message', {life: 1000, theme: 'jGrowl-green'}); " &
    "setTimeout(function(){ location.reload(); },1000);" &
    "});" &"void(0);";
    var text button  = "<a class='Vibrant Primary' href=\"" & $url &"\">My button text</a>";

    $button


  • 7.  RE: URL formula to edit a record and ""refresh the page

    Posted 01-12-2023 11:16
    Hi there,
    I realize this is a very old post and my issue may be because of this, but hoping to get some insight into how to do this. 

    I have a number field I'm trying to increase in a Kanban report with a button click, then refresh the data on the page (even better if we could use Ajax).

    I'm trying to create this in a Formula - URL button but when I go to save , I get the error:

    There are one or more problems with your entry

    Only text, Quickbase-accepted functions, fields, variables, and certain HTML tags are allowed in this field. JavaScript is not supported.


    Here is my code:

    var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Task ID]
    & "&apptoken=XXXXX"
    & "&_fid_76=" & [Duration Plus One];

    "javascript:" &
    "$.get('" &
    $URL &
    "',function(){" &
    "location.reload(true);" &
    "});"
    & "void(0);"

    Any help is much appreciated! Thanks!

    ------------------------------
    Carrie Krakowski
    ------------------------------



  • 8.  RE: URL formula to edit a record and ""refresh the page

    Posted 01-12-2023 11:27
    Edited by Mark Shnier (Your Quickbase Coach) 01-12-2023 11:57
    Right, so they took away JavaScript from us and we used to use it to refresh the page. But they gave us a new replacement code.  The code in bold below will refresh whatever page you are on even if you click a button on an embedded child report on a form for example. 

    Do you need the generic syntax below in this format.
    $URLONE 
    & "&rdr=" & URLEncode($URLTWO) 

    So, in your use case you want to do the update and then you want to refresh the page.

    var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Task ID]
    & "&apptoken=XXXXX"
    & "&_fid_76=" & [Duration Plus One];

    var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();
     
    $URL
    & "&rdr=" & URLEncode($RefreshPage)

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



  • 9.  RE: URL formula to edit a record and ""refresh the page

    Posted 01-12-2023 11:37
    Beautiful! Works perfectly. Thank you for the speedy response!

    ------------------------------
    Carrie K
    ------------------------------



  • 10.  RE: URL formula to edit a record and ""refresh the page

    Posted 11-29-2014 22:38
    Works great! Thanks


  • 11.  RE: URL formula to edit a record and ""refresh the page

    Posted 02-22-2015 04:54
    how would i do this in reverse, i want the refresh to happen before the URL ?


  • 12.  RE: URL formula to edit a record and ""refresh the page

    Posted 02-22-2015 17:11
    Can you explain what you're trying to do?  If you're going to go to the URL anyway - why not go to the URL directly, without the refresh?  What does the initial refresh accomplish?


  • 13.  RE: URL formula to edit a record and ""refresh the page

    Posted 02-23-2015 16:16
    I have a parent table that shows in a record a link to records in the child table.  The child table contains cases that a user can assign to them self to work, using a custom "Get" button that shows in the link report.  When they click the "Get" button it changes some values in the child record using API_EditRecord to assign the case to that person.  The problem is, if someone else hits the "Get" button at the same time or moments after that second person will take the case from the first person because the report hasn't refreshed.   If I could refresh first I could test the child record to make sure it's not already assigned and therefore not risk someone getting a case that someone else already has.


  • 14.  RE: URL formula to edit a record and ""refresh the page

    Posted 02-23-2015 16:35
    In that case, try this:

    var text URL= URLRoot() & "db/" & [_DBID_TABLE_1] & "?act=API_EditRecord"
    & "&rid=" & URLEncode ([Record ID#])
    & "&_fid_7=" & URLEncode ([Status])
    & "&apptoken=" & "XXXX";

    "javascript:" &
    "location.reload(true);" &
    "$.get('" &
    $URL &
    "');" &
    "void(0);"

    Here are the key parts of the javascript portion:

    "location.reload(true);" - This first does the reload

    "$.get('" & $URL & "');" - This uses the $.get function to run the URL.  In this case, you don't need a success function to run after the URL.

    Hopefully this does what you want.


  • 15.  RE: URL formula to edit a record and ""refresh the page

    Posted 02-23-2015 17:45
    Thanks, however it looks like whether I reload before or after I get the same result.  Basically what is happening is I have a summary filed that tells me what the oldest record # is in the child table.  So let's say it shows record#100 as the oldest, when I click my GET button it gets that record number.  If someone else then hits GET and hasn't refreshed recently it also gets record# 100 for that person.  I was hoping doing the reload first would update the summary field to move to the next record number but apparently it does not.  Any thoughts on how I could achieve this?


  • 16.  RE: URL formula to edit a record and ""refresh the page

    Posted 02-23-2015 18:04
    What exactly is your GET button doing?  Is it editing a record?  Inserting a new record (and thus changing the [Maximum Record ID#])?

    If [Maximum Record ID#] is a summary field, and you already have access to that summary field from your child record (by looking up the summary field in the parent table), you can insert that [Maximum Record ID#] directly into your URL (to indicate record to edit).

    Can you try the following and let me know what you find:

    Put the [Maximum Record ID#] as a column in your report.  Then let me know what happens to the [Maximum Record ID#] - before and after you hit the GET button, etc.

    From what I've seen, the [Maximum Record ID#] updates right away on refresh - so there's something I'm not understanding about what your app is doing.

    Please also outline your table structure - the parent, child table, where the GET button is, what it's doing, etc.


  • 17.  RE: URL formula to edit a record and ""refresh the page

    Posted 09-28-2017 05:52
    I have the similar requirement where my URL button is a part of report called 'unassigned Queue' which is attached to dashboard of the user role.  We have 50+ users working at the same time and they click on 'Assign To Me' button of the report to get the record assigned to me for further editing.

    I also have a quickbase action set on the same table which creates a new record in log table and then a summary field (count of records) in the main table.  I used the if condition to check if child record count is 0 then assign else redirect to home /dashboard page of the user.

    Below is the code I used.
    "Assign To Me" - Formula URL field

    var text URL=
    If ( [#Check-Assigned For FLR]<=0,
    URLRoot() & "db/"&Dbid()&"?act=API_EditRecord&rid="&[Record ID#]& "&_fid_10=" & URLEncode("Assigned For FLR" ) &  ---- record status field.
    "&_fid_12=" & URLEncode(UserToEmail(User())) &  ---- Current User
    "&_fid_14=" & URLEncode(UserToEmail(User())) &  ---- Current User
     "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() &"?a=td")
    ,
    URLRoot() & "db/" & Dbid() &"?a=td");

    "javascript:" &
    "location.reload(true);" &
    "$.get('" &
    $URL &
    "');" &
    "void(0);"

    I noticed random results with above code.
    - If multiple users click on the button at the same time, anyone gets the records and not the first user who clicked (based on first related child record generated).
    - secondly the redirection to home page dosen't happen always. Few users are refreshed to report to show the same results prior to click wherein the record is already been assigned to someone else. 
    - The record moves-off the queue when user manually clicks on home page or refreshes the browser page.

    Questions:
    1) How Do I redirect users back to home page and refresh my report so that record moves-off to the one who clicked first?
    2) Is there a way to display message using java script  (something liek oops.. record already picked by different user) and redirect back to refresh queue/home page ?


  • 18.  RE: URL formula to edit a record and ""refresh the page

    Posted 01-28-2018 01:48
    Is there a way to make this work where the user's page is refreshed and it keeps a search term in the built in search bar? 

    The dynamic filters are nice and all, but my users are currently scanning a bar code into the search bar which filters the report down to 5 or 6 relevant records. They then click URL buttons to update status on a few of these relevant records. 

    Every time they click one of my URL buttons, it refreshes the page and even though the search bar is still populated, and I see the search term in the URL, the report does not filter until we hit "Search" (or Enter on the keyboard).

    My code is below: 

    var text URL = 
    URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
    & "&_fid_7="&URLEncode("Complete");

    "javascript:" &
    "$.get('" & 
    $URL & 
    "',function(){" &
    "location.reload(true);" &
    "});" 
    & "void(0);


  • 19.  RE: URL formula to edit a record and ""refresh the page

    Posted 01-28-2018 01:53
    This technique will leave the screen I disturbed.

    Try replacing that JavaScript part with this

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

    Choose your words.

    The 5000 means 5 seconds for the quiet pop up to fade away.


  • 20.  RE: URL formula to edit a record and ""refresh the page

    Posted 01-28-2018 07:01
    This code is working as described.

    I think by adjusting the words to include something like "Reload browser to update changes"  I can make this work for my needs. 

    Thanks very much for the help.