ContributionsMost RecentMost LikesSolutionsRe: Button that redirects instead of refreshes same page.Any thoughts? ------------------------------ Alex Bennett ------------------------------ Button that redirects instead of refreshes same page.Hello, I've made a button using the following app as a reference: Using Code Pages to Refresh with a Delay I'm able to check a box, and see the circle loading based on duration set, however, I can't seem to get it to redirect back instead of refreshing. Formula-URL Button: //URLRoot() & "db/" & [_DBID_JOBS] & "?a=dr&dfid=2&rid=" & [Related Job]& "&z=" & Rurl() // Creating a toggle for the Checkbox var text toggle = If([Approved?], "false", "true"); // API URL to Add/Edit/etc. var text urlToExecute = URLRoot() & "db/" & "bp2qqgq8x" & "?a=API_EditRecord&apptoken=" & "dw5sqifgqvf48cfibdphd5kc8ie" & "&rid=" & [Record ID#] & "&_fid_294=" & $toggle; URLRoot() & "db/" & AppID() & "?a=dbpage&pageid=27" // Open code page 27 & "&url=" & URLEncode($urlToExecute) // Pass in the URL to execute Code Page Code: <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <title>Loading...</title> <style> .loader { border: 16px solid #f3f3f3; border-radius: 50%; border-top: 16px solid #3498db; width: 160px; height: 160px; -webkit-animation: spin 1s linear infinite; /* Safari */ animation: spin 1s linear infinite; display: block; margin-left: auto; margin-right: auto; margin-top: 250px; } /* Safari */ @-webkit-keyframes spin { 0% { -webkit-transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); } } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } </style> </head> <body> <script src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js'> </script> <script> function Run() { let urlParams = new URLSearchParams(window.location.search); let url = urlParams.get('url'); let redirect = urlParams.get('redirect'); let landing; if(redirect){ landing = redirect; }else{ landing = document.referrer; } fetch(url, { method: 'post', mode: 'no-cors', headers: { 'Content-type': 'text/plain' } }).then((response) => { setTimeout(function () { errRdr();} , 2000); // # of milliseconds to pause for, 2000 = 2 seconds }) } function errRdr(){ // Redirects to the previous page, if this page was the previous page as well, then redirect to the app home page if(document.referrer && document.referrer !== window.location.href) { window.location.href = document.referrer; }else{ window.location.href = window.location.origin + window.location.pathname; } } Run(); </script> <!--<h2 class="info", style="text-align:center">Approving, Saving and Redirecting...</h2>--> <div class="loader"></div> </body> </html> Any thoughts on how I can get this to redirect back after checking and saving the page, displaying the code page for the "Loading Circle" waiting for the previous page to update before display. ------------------------------ Alex Bennett ------------------------------ Render data using QuickBase's RESTful API in React?Hey everyone, I wanted to see if anyone could give me any help for getting some QuickBase data to render using an api call in React. I'm attempting to pull field values from 2 tables in our app to be able to use for outside software, I'm able to get the data to show up in the console. but not when I attempt to render it on screen or call specific fields in the api. import React, { Component } from 'react' let headers = { 'QB-Realm-Hostname': 'XXXXXXXXXX.quickbase.com', 'User-Agent': 'FileService_Integration_V2.1', 'Authorization': 'QB-USER-TOKEN XXXX_XXXXX_XXXXXXXXXXXXXX', 'Content-Type': 'application/json' }; class JobsTableApi extends Component { state = { data: null, } componentDidMount() { this.fetchData(); } fetchData = () => { let body = {"from":"bpz99ram7","select": [3,6,80,81,82,83,86,84,88,89,90,91,92,93,94,95,96,97,98,99,101,103,104,105,106,107,109,111,113,115,120,123,224,225,226,227,228,229,230,231,477,479,480,481],"sortBy":[{"fieldId":6,"order":"ASC"}],"groupBy":[{"fieldId":40,"grouping":"equal-values"}],"options":{"skip":0,"top":0,"compareWithAppLocalTime":false}} fetch('https://api.quickbase.com/v1/records/query', { method: 'POST', headers: headers, body: JSON.stringify(body) }).then(res => { if (res.ok) { return res.json().then(res => { this.setState({ data: [], }) }); } return res.json().then(resBody => Promise.reject({status: res.status, ...resBody})); }).catch(err => console.log(err)) } render() { const { data } = this.state; if (data === null) return 'Loading...'; return ( <div> <h3> {data[18]} </h3> </div> ) } } export default JobsTableApi; Hopefully someone can help me with this is I can't get anything to render! Thanks! ------------------------------ Alex Bennett ------------------------------ Re: QuickBase API POST vs GETOk, my thoughts as well and still using the POST method to get the 'data' for all these fields I'm pulling over. Felt like I should have been using GET for that, but if POST will accomplish my same goal then I'm fine with it. Just wanted to double-check with those more experienced in the New QuickBase API! Thanks Justin! ------------------------------ Alex Bennett ------------------------------ Re: QuickBase API POST vs GETFor POST I'm using '/records/query', which i get from the documentation when setting up the example api call. For GET I'm using '/fields/usage?tableId={tableId}&skip={skip}&top={top}, again from the documentation. I'm just trying to get field values to be able to display in some custom line charts. ------------------------------ Alex Bennett ------------------------------ QuickBase API POST vs GETHey Everyone, Wanted to see if I could get some advice/input on using different methods for the RESTful JSON API. I've been messing around with the API calls on a custom application to see if I could bring this data in and just use the values of these fields from our QuickBase. I have been able to make the API call and am getting field values from the POST Method, but if I attempt to do a GET method I only can get the field ID info (numeric, Field ID#, Field Name, etc) but never what values have been inputted in that field. Is there something I'm doing wrong? I feel as though I should be using GET for this purpose of just wanting to get the data from QuickBase and display it as needed for 'Read-only' purposes. Any help would be appreciated! Thanks, ------------------------------ Alex Bennett ------------------------------ Re: QuickBase API "Query for Data" body helpUPDATE: I found my issue, it was in my syntax, I'm leaving the Array blank to include all fields from the designated table, but had my syntax formatted wrong due to trying to convert over from the method "GET" to "POST". Here is my updated API call for reference for anyone else having issues. var headers = { 'QB-Realm-Hostname': 'XXXXXXXXXXXX.quickbase.com', 'User-Agent': 'FileService_Integration_V2.1', 'Authorization': 'QB-USER-TOKEN XXXXXXXX_XXXXXXXXX_XXXXXXXXXXXXXXXXX', 'Content-Type': 'application/json' } var body = {"from":"bpz99ram7","select":[],"sortBy":[{"fieldId":6,"order":"ASC"}],"groupBy":[{"fieldId":6,"grouping":"equal-values"}],"options":{"skip":0,"top":0,"compareWithAppLocalTime":false}} fetch('https://api.quickbase.com/v1/records/query', { method: 'POST', headers: headers, body: JSON.stringify(body) }) .then(res => { if (res.ok) { return res.json().then(res => console.log(res)); } return res.json().then(resBody => Promise.reject({status: res.status, ...resBody})); }) .catch(err => console.log(err)) ------------------------------ Alex Bennett ------------------------------ QuickBase API "Query for Data" body helpHey Everyone, I'm attempting to do an API call in an external application to pull some data over from our QuickBase to be able to manipulate other charts and graphs outside of QuickBase based on these field data values. I wondered if anyone had any input on how to form the body properly, I'm reading maybe using the API_DoQuery call with clist of all field ID's? I was able to make the call getting the field id's at names pulled over, but no data yet. var headers = { 'QB-Realm-Hostname': 'XXXXXXXXX.quickbase.com', 'User-Agent': 'FileService_Integration_V2.1', 'Authorization': 'QB-USER-TOKEN XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'Content-Type': 'application/json' } // var body = { // "from": "bpz99ram7", // "select": [], // "sortBy": [ // { // "fieldId": 6, // "order": "ASC" // }, // ], // } fetch('https://api.quickbase.com/v1/fields/usage?tableId=bpz99ram7&skip=0&top=0', { method: 'GET', headers: headers, //body: JSON.stringify(body) }) .then(res => { if (res.ok) { return res.json().then(res => console.log(res)); } return res.json().then(resBody => Promise.reject({status: res.status, ...resBody})); }) .catch(err => console.log(err)) As you can see above, I've commented out the 'body' and changed the method to GET, I believe I need to have the body with the field ID's being pulled over, and changing the method type to POST, but am getting 405 error (Method Not Allowed) whenever I attempt to use a body and method type of POST. Again, the idea is to pull over field values to be able to be used in custom software charts and graphs based on what is in these fields in QuickBase. Any help would be greatly appreciated! Edit: I know the "select" array for field ID's is blank, when I added field ID's I still got errors. This code also works and I can see in my Console that I'm getting all the field ID's from that table and their corresponding field names, but not values which is why I'm attempting to switch to "Query for Data". Thanks!! ------------------------------ Alex Bennett ------------------------------Re: Multi-Select Text Formula HelpCan I ask you this, I already have a formula that shows what options are "Existing" and should not be able to be selected if they are trying to add a "new" option. If there is a way to only show options that are NOT Included in this field, then I could use a Dynamic Form Rule to Change my Multi Select field to these options, if they select the type to add new option. ------------------------------ Alex Bennett ------------------------------ Re: Multi-Select Text Formula HelpSo with the above code, would I have to change my Parent choices to be designated by Letters? A. Choice One, B. Choice Two, C. Choice Three, etc? I also know that QuickBase is going to no longer be supporting JavaScript in formula fields unless it's within a code page, would this apply to that as well? ------------------------------ Alex Bennett ------------------------------