Forum Discussion

KenCasser's avatar
KenCasser
Qrew Cadet
7 years ago

&rdr="" in JavaScript not working

Here is my JavaScript code:

var date = new Date();
var yr = date.toDateString().substr(-2);
var mo = date.getMonth()+1;
var d = date.getDate();

var b = kRid;

console.log(kRid);

var URLONE = document.location.href = "https://ME.quickbase.com/db/DBID?act=API_EditRecord&rid="+kRid+"&_fid_...; "+d+", "+yr+" &_fid_10=Changed Project";

var URLTWO = document.location.href="https://ME.quickbase.com/db/DBID?a=er&rid="+(b);

$URLONE

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

console.log(b-1);

If we forget about using var URLONE & var URLTWO and instead test each of these lines separately, they work.  Using the first line alone, it edits the current record, gives me the console.log(b-1) which is one number less than the current record number (just for testing), but after doing that it I get the Success message.  So I hit the 'back' button and I can see the current record has been edited.  Using the second line alone, it brings the current record into its Edit mode, and I also get the correct console.log(b-1) confirmation that my code has gone its full length.  But, when I try to run the two lines concurrently, it seems to skip the first line (ie it doesn't change the fields per my request) and only brings me to the edit screen for the current record.  And, it does not give me the console.lot(b-1) confirmation.  PS - using var b = kRid has been part of my testing.  It works whether I use kRid or b, but I haven't cleaned things up yet.

Please help.  I'm so close to my goal I can taste it.  Thank you!

18 Replies

  • The example I posted was for a formula Rich text field as it makes a hyperlink.  The alternative would be to just have a red URL formula button as a formula URL field.

    I that case it would be a simpler formula

    var text URL= URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
    & "&_fid_50=" // blank out copy of indicator
    & "&_fid_15=" & ToText(Today())  // set date to today
    & "&_fid_31=0" // uncheck Completed
    & "&_fid_40=0"; // uncheck Reviewed


    If([Copy Of Indicator used in Copy Master Detail]<>"",

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


    If it wuz me, I would just do the two click method, get 'er done and move on to the next thing on my long todo list.
  • Not to drag you farther down this road but, how do I make a Formula-Rich Text field into a hyperlink?  I don't see an option to make this field into a button and it just sits there.
  • I would have to see your code to help you debug.

    If you start with just a formula URL button there is less code.