Discussions

 View Only
  • 1.  Magic Buttons Code - Return Instead of Redirect

    Posted 11-08-2019 11:35
    I'm using code that I got from the Magic Buttons app for the % complete bar. I've added a few things to it and it works great except for one thing... I want to select a little green box while on a report and it refresh and return to where I was originally. It's currently taking me to the record after clicking. I had thought the "location.reload();" part meant it would return instead of redirecting, so I'm not sure how to fix this myself. 

    var date todaysDate = Today();
    var text star = "<img" & " src=\"" & "https://images.quickbase.com/si/16/228-rect_green.png\">";
    var text notstar = "<img" & " src=\"" & "https://images.quickbase.com/si/16/226-rect_gray.png\">";
    var number numberstars = (Floor([% Complete] * 10));
    var number numbernotstars = 10 - $numberstars;
    //10 is the number of units, because 10 is 1/10th of 100.
    
    var text urlten =
    
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Task ID] &
    "&_fid_143=In Progress" &
    "&_fid_99= null" &
    "&_fid_166=10";
    
    var text urltwenty =
    
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Task ID] &
    "&_fid_143=In Progress" &
    "&_fid_99= null" &
    "&_fid_166=20";
    
    var text urlthirty =
    
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Task ID] &
    "&_fid_143=In Progress" &
    "&_fid_99= null" &
    "&_fid_166=30";
    
    var text urlforty =
    
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Task ID] &
    "&apptoken=c9bkn8zd9zgnanc25bhq6cvh87cr" &
    "&_fid_143=In Progress" &
    "&_fid_99= null" &
    "&_fid_166=40";
    
    var text urlfifty =
    
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Task ID] &
    "&_fid_143=In Progress" &
    "&_fid_99= null" &
    "&_fid_166=50";
    
    var text urlsixty =
    
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Task ID] &
    "&_fid_143=In Progress" &
    "&_fid_99= null" &
    "&_fid_166=60";
    
    var text urlseventy =
    
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Task ID] &
    "&_fid_143=In Progress" &
    "&_fid_99= null" &
    "&_fid_166=70";
    
    var text urleighty =
    
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Task ID] &
    "&_fid_143=In Progress" &
    "&_fid_99= null" &
    "&_fid_166=80";
    
    var text urlninety =
    
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Task ID] &
    "&_fid_143=In Progress" &
    "&_fid_99= null" &
    "&_fid_166=90";
    
    var text urlhundred =
    
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Task ID] &
    "&_fid_99="&$todaysDate&" " &
    "&_fid_143=Completed" &
    "&_fid_166=100";
    
    "<span alt=\"" & ToText($numberstars) & " of 10 \" title=\"" & ToText($numberstars) & " of 10 \" class=\"NoWrap\">" &
    
    If($numberstars >= 1, "<a href=\"javascript:" & "$.get('" & $urlten & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/228-rect_green.png'></a>",
    "<a href=\"javascript:" & "$.get('" & $urlten & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/226-rect_gray.png'></a>") &
    If($numberstars >= 2, "<a href=\"javascript:" & "$.get('" & $urltwenty & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/228-rect_green.png'></a>",
    "<a href=\"javascript:" & "$.get('" & $urltwenty & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/226-rect_gray.png'></a>") &
    If($numberstars >= 3, "<a href=\"javascript:" & "$.get('" & $urlthirty & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/228-rect_green.png'></a>",
    "<a href=\"javascript:" & "$.get('" & $urlthirty & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/226-rect_gray.png'></a>") &
    If($numberstars >= 4, "<a href=\"javascript:" & "$.get('" & $urlforty & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/228-rect_green.png'></a>",
    "<a href=\"javascript:" & "$.get('" & $urlforty & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/226-rect_gray.png'></a>") &
    If($numberstars >= 5, "<a href=\"javascript:" & "$.get('" & $urlfifty & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/228-rect_green.png'></a>",
    "<a href=\"javascript:" & "$.get('" & $urlfifty & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/226-rect_gray.png'></a>") &
    If($numberstars >= 6, "<a href=\"javascript:" & "$.get('" & $urlsixty & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/228-rect_green.png'></a>",
    "<a href=\"javascript:" & "$.get('" & $urlsixty & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/226-rect_gray.png'></a>") &
    If($numberstars >= 7, "<a href=\"javascript:" & "$.get('" & $urlseventy & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/228-rect_green.png'></a>",
    "<a href=\"javascript:" & "$.get('" & $urlseventy & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/226-rect_gray.png'></a>") &
    If($numberstars >= 8, "<a href=\"javascript:" & "$.get('" & $urleighty & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/228-rect_green.png'></a>",
    "<a href=\"javascript:" & "$.get('" & $urleighty & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/226-rect_gray.png'></a>") &
    If($numberstars >= 9, "<a href=\"javascript:" & "$.get('" & $urlninety & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/228-rect_green.png'></a>",
    "<a href=\"javascript:" & "$.get('" & $urlninety & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/226-rect_gray.png'></a>") &
    If($numberstars >= 10, "<a href=\"javascript:" & "$.get('" & $urlhundred & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/228-rect_green.png'></a>",
    "<a href=\"javascript:" & "$.get('" & $urlhundred & "', function(){" & "location.reload();" & "});" & "void(0);\"><img src='https://images.quickbase.com/si/16/226-rect_gray.png'></a>") &
    "</span>"​

    #magicbuttons ​​​​​

    ------------------------------
    Courtney F.
    ------------------------------


  • 2.  RE: Magic Buttons Code - Return Instead of Redirect

    Posted 11-08-2019 17:44
    The issue seems to be coming from the whole row being clickable. 

    Uncheck allow editing and allow viewing on the report, and the green bar will work as you want it to, i.e. click and return to report. 

    If you want users to still be able to view/edit records from that report, you can make custom icons for that report




    ------------------------------
    Everett Patterson
    ------------------------------



  • 3.  RE: Magic Buttons Code - Return Instead of Redirect

    Posted 11-09-2019 00:32
    Everett, I appreciate your reply; that does seem to be a workaround.

    I'd still like to know why this particular formula has this issue when other buttons I use work properly. I had a standard formula on a button that upon clicking, it would change the task status to Completed, then refresh on the report page. No report settings need to be changed for that to not redirect. This is a pretty lengthy formula, but I would assume it should work the same way. Any other ideas?

    ------------------------------
    Courtney F.
    ------------------------------



  • 4.  RE: Magic Buttons Code - Return Instead of Redirect

    Posted 11-09-2019 17:58
    I think that Everett is correct.  Perhaps you were remembering the behaviour of other buttons when used on a on a record, not a report.

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    markshnier2@gmail.com
    ------------------------------



  • 5.  RE: Magic Buttons Code - Return Instead of Redirect

    Posted 11-09-2019 19:06
    Mark,
    This is another code from Magic Buttons that I use on many reports to change a status and it returns to the report I was on originally. 
    var text url =
    
        URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
        "&rid=" & [Task ID] &
        "&_fid_143=Completed" &
        "&_fid_166=100";
    
    "<a class=\"Vibrant Success\" href=\"javascript:" & "$.get('" & $url &
        "', function(){" & "location.reload();" & "});" &
        "void(0);\">15B. Change the status to completed and return</a>"​

    Are you saying that the original button code I had posted can't be coded to refresh while on a report? 



    ------------------------------
    Courtney F.
    ------------------------------



  • 6.  RE: Magic Buttons Code - Return Instead of Redirect

    Posted 11-10-2019 09:14
    Re:Are you saying that the original button code I had posted can't be coded to refresh while on a report? 

    The code for the Magic Buttons app is different as it is not using images.  I do know that when you make and simple formula Rich Text hyperlink which uses this syntax

    <a href=" & $URL & ">" & $WordsOrImage & "</a>"

    Then clicking that button on a report will have an inadvertent effect to open up the record to view.  Your magic buttons example does seem to use that syntax.

    I don't know of a way to recode it, but I can't say that there is not a way to recode it.

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    markshnier2@gmail.com
    ------------------------------



  • 7.  RE: Magic Buttons Code - Return Instead of Redirect

    Posted 11-10-2019 09:23
    I appreciate both of your replies. I was honestly just looking for why it might be happening that way, so that's an explanation I can understand. I will try Everett's advice and move on. Thank you!

    ------------------------------
    Courtney F.
    ------------------------------