Is it possible to use API to call a record and then sort ascending and descending a specific column as two links that I can attach to buttons?

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered
Photo of Robert

Robert

  • 30 Points

Posted 3 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,208 Points 50k badge 2x thumb
Are you asking if you can have buttons on a report to sort a report either ascending or descending.  Why not just click that column header to sort?
Photo of Jack

Jack, Champion

  • 50 Points
You could also just copy the report and predefine one as A-Z and one as Z-A and then add both buttons to your dashboard.

If this or the above isn't what your after please can you post some additional detail.
Photo of Robert

Robert

  • 30 Points
we had to restrict users roll to not create any new reports. doing this disabled the ability to sort.
Photo of Jack

Jack, Champion

  • 50 Points
The above then is your most logical solution in this case. The sort options can be found in the report settings near the bottom.
Photo of Robert

Robert

  • 30 Points
The number of reports needed to be copied would clutter the system and I am trying to avoid this option. I am new to quickbase and API  but to my understanding isnt this what I should be using? https://[sourceurl]/db/[databaseID]?a=DoQuary&qid=110&options=sortorder-A&[ticket]&[token]
the report in this case is 110
Photo of Jack

Jack, Champion

  • 50 Points
Photo of Robert

Robert

  • 30 Points
Ok follow up question after many frustrating hours I have found that I was using the incorrect query type to begin with and it was executing in XML. If i have say 6 different columns each of which id like to sort either ascending or descending how would i select which column to sort?
https://[sourceurl]/db/[databaseID]?a=API_GenResultsTable&qid=110&apptoken=[token]&_curuser_&clist=a&options=sortorder-D
Photo of Jack

Jack, Champion

  • 50 Points
Using slist you can specify the default sort column.

https://www.quickbase.com/api-guide/index.html#gen_results_table.html%3FTocPath%3DQuickBase%2520API%2520Call%2520Reference%7C_____33

You can find details on it on the above link.
Photo of Robert

Robert

  • 30 Points
I am going to update this based on what I had to do in order to fix this to help others.



Firstly The dashboard calls a webpage that I made in quickbase for each report its calling

The webpage calls a css+java commands and has the basic layout

The results of this will make sure the end user never sees the URL in the first place.

This is trimmed and edited for sensitive information and because i dont feel like editing all of them for removing of the tokens:





<link rel="stylesheet" type="text/css" href="[thisdatabaseID]?a=dbpage&amp;pageID=38">

<!--<script src="[thisdatabaseID]?a=dbpage&amp;pageID=39"></script>-->

<!--Purchaser Contact-->

<b>PURCHASER CONTACT</b>

<a href="[DBrecordstorageID]?a=API_GenResultsTable&amp;qid=111&amp;apptoken=[TokenID]&amp;slist=589&amp;options=sortorder-A" target="custFrame" class="acenButton">▲</a>

<a href="[DBrecordstorageID]?a=API_GenResultsTable&amp;qid=111&amp;apptoken=[TokenID]&amp;slist=589&amp;options=sortorder-D" target="custFrame" class="decButton">▼</a>



<!--Space-->&nbsp;||<p></p>



<iframe id="custFrame" name="custFrame" src="[DBrecordstorageID]?a=API_GenResultsTable&amp;qid=111&amp;apptoken=[TokenID]&amp;slist=18&amp;options=sortorder-A" marginheight="0" frameborder="0" width="100%" height="80%"> </iframe>



<script>

var socket = new easyXDM.Socket({

    onReady:  function(){

        socket.postMessage(document.body.scrollHeight)

   }

});

</script>
Photo of Robert

Robert

  • 30 Points
The contents of the CSS file:(ID38 in the above):
--start--
.decButton {
-moz-box-shadow: 0px 10px 14px -7px #cf866c;
-webkit-box-shadow: 0px 10px 14px -7px #cf866c;
box-shadow: 0px 10px 14px -7px #cf866c;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #d0451b), color-stop(1, #bc3315));
background:-moz-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background:-webkit-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background:-o-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background:-ms-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background:linear-gradient(to bottom, #d0451b 5%, #bc3315 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d0451b', endColorstr='#bc3315',GradientType=0);
background-color:#d0451b;
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
border:1px solid #942911;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:10px;
padding:2px 2px;
text-decoration:none;
text-shadow:0px 1px 0px #854629;
}
.decButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #bc3315), color-stop(1, #d0451b));
background:-moz-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background:-webkit-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background:-o-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background:-ms-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background:linear-gradient(to bottom, #bc3315 5%, #d0451b 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#bc3315', endColorstr='#d0451b',GradientType=0);
background-color:#bc3315;
}
.decButton:active {
position:relative;
top:1px;
}
.acenButton {
-moz-box-shadow: 0px 10px 14px -7px #3e7327;
-webkit-box-shadow: 0px 10px 14px -7px #3e7327;
box-shadow: 0px 10px 14px -7px #3e7327;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #77b55a), color-stop(1, #72b352));
background:-moz-linear-gradient(top, #77b55a 5%, #72b352 100%);
background:-webkit-linear-gradient(top, #77b55a 5%, #72b352 100%);
background:-o-linear-gradient(top, #77b55a 5%, #72b352 100%);
background:-ms-linear-gradient(top, #77b55a 5%, #72b352 100%);
background:linear-gradient(to bottom, #77b55a 5%, #72b352 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#77b55a', endColorstr='#72b352',GradientType=0);
background-color:#77b55a;
-moz-border-radius:4px;
-webkit-border-radius:4px;
border-radius:4px;
border:1px solid #4b8f29;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:10px;
font-weight:bold;
padding:2px 2px;
text-decoration:none;
text-shadow:0px 1px 0px #5b8a3c;
}
.acenButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #72b352), color-stop(1, #77b55a));
background:-moz-linear-gradient(top, #72b352 5%, #77b55a 100%);
background:-webkit-linear-gradient(top, #72b352 5%, #77b55a 100%);
background:-o-linear-gradient(top, #72b352 5%, #77b55a 100%);
background:-ms-linear-gradient(top, #72b352 5%, #77b55a 100%);
background:linear-gradient(to bottom, #72b352 5%, #77b55a 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#72b352', endColorstr='#77b55a',GradientType=0);
background-color:#72b352;
}
.acenButton:active {
position:relative;
top:1px;


--end--
Contents of the Java script:(ID39 in the above):
--start--
new easyXDM.Socket({
    remote: "http://provider.easyxdm.net/example/resized_iframe.html",
    container: document.getElementById("container"),
    onMessage: function(message, origin){
        this.container.getElementsByTagName("iframe")[0].style.height = message + "px";
    }
});
--end--
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
I can't follow this thread as there appears to be a wandering focus. It is interesting that you are using easyXDM but why is that necessary as presumably the user is operating out of a single domain - there is no cross domain issue present as far as I can tell.
Photo of Robert

Robert

  • 30 Points
I didn't write the external javascript my mentor did I worked on the main page and the css design javascripting is something I am still learning. Once we found out about resolving our issue in this manner we where able to apply the same concept multiple times over on different systems for scripting and have sense even cut down on the total number of fields needed for some calculations.


The main issue is we revoked the managers privileges for sorting, by revoking access to manipulate reports (add/modify/delete) They needed these specific reports to have multiple sorting options. Originally this was all stored in buttons but after my mentor saw what I was doing he told be about adding them to a webpage instead where we would be able to hide the token information to avoid anyone from getting wise.