Forum Discussion
_anomDiebolt_
Qrew Elite
You would have to save the current tab in localStorage after every tab change and read it back in when the form reopens and set the current tab. This is how QuickBase remembers open sections on a per user basis.
This is not something I would contribute publicly so if you want to pursue a solution feel free to contact me off-world using the information in my profile:
https://quickbase-community.intuit.com/users/513/
This is not something I would contribute publicly so if you want to pursue a solution feel free to contact me off-world using the information in my profile:
https://quickbase-community.intuit.com/users/513/
JoshuaTate
7 years agoQrew Cadet
So the Quickbase Tab Handler doesn't work as expected in most situations. if anyone has this issue the below code block will give you a starting hand in getting a solution to the problem which you could extend to other purposes. I have also provided a code flow diagram. This script is used in conjunction with the function in the above comment with both applied to either a IOL or BOL tag.
//Add an event listener on all href tags which include #tab, this will trigger the function to run every time you change tabs.
$('a[href^="#tab"]').on('click', sendMeBackRight(event))
//lets define our function thats run on each event trigger above
function sendMeBackRight(event) {
//below we set our realm variable
var realmName = "unimatrix001"
//gets the hash from the event
var EvName = event.target.hash;
//Below setsup all Regular Expressions required for the whole function
var regexEdPg = new RegExp(/(&z=.+?.{1,10}(?='))/);
var regexP = new RegExp(/(\?a=.+?(?=&))/);
var regexPt = new RegExp(/(\?a=.+?.{1,6})/);
var regexPrd = new RegExp(/(&z=.+?.{1,10})/);
var regexNuR = new RegExp(/(\&nexturl=.+?.{1,100})/);
var regexNeD = new RegExp(/(\&nexturl=.+?.{1,100})(?=')/);
//setup variable for the location
var regLocS = document.location.search;
//below we test 2 situations and set a variable accordingly, we look for the action and make it a variable to apply to the return string.
if (regexP.test(regLocS) !== null) {
var regRedV = regLocS.match(regexP)[0];}
if (typeof regRedV === 'undefined') {
if (regexPt.test(regLocS) !== null) {
var regRedV = regLocS.match(regexPt)[0];}}
if (typeof regRedV !== undefined) {
//Only if the action type is found and set to variable do we move on to encode and build the next url string to be applied to all href tags in scope as well as onclick event for edit record buttons. does apply to new records but gets overwritten by the onclick function - you can write your own handler for this if you like.
if (regRedV !== null) {
var conChe = encodeURIComponent(EvName);
var conChD = encodeURIComponent(regRedV);
//Below is the literal block to build our return path
var lstVisResSS = '&nexturl=https%3A%2F%2F${realmName}}.quickbase.com%2Fdb%2F${gDBID}${conChD}%26rid%3D${kRid}${conChe}';
//set a variable with selector to obtain then loop through each add href tag in the form that contains text 'Add' and the class 'vibrant', just add a code block for other URLs like save and close etc for edit forms back to same tab in view record and so on.
var daTagz = $("a:contains('Add')[class='Vibrant']");
let vibUrlLen = $("a:contains('Add')[class='Vibrant']").length;
for (let i = 0; i < vibUrlLen; i++) {
var resToPro = "";
//if the href tag includes the z redirect we strip it and add the current tab info
if (daTagz.href.includes("&z=")) {
//using regexp replace the z with the nexturl
resToPro = daTagz.href.replace(regexPrd,lstVisResSS);
//apply the attribute to the element
daTagz.setAttribute('href', resToPro);
} else if (daTagz.href.includes("&nexturl=")) {
//this updates previously set urls with the latest tab
resToPro = daTagz.href.replace(regexNuR,lstVisResSS);
daTagz.setAttribute('href', resToPro);
//the below block similar to above handles onclick href in add and edit screens, remember it works for edit, for add you will need to extend to handle add or remove it from scope only in this situation.
} else if (typeof daTagz.attributes.onclick !== 'undefined') {
var edPgVa = daTagz.attributes.onclick.value;
if (regexEdPg.test(edPgVa) !== false) {
var pgEdVa = edPgVa.replace(regexEdPg,lstVisResSS);
daTagz.setAttribute('onclick', pgEdVa);
} else if(regexNeD.test(edPgVa) !== false) {
var pgEdNr = edPgVa.replace(regexNeD,lstVisResSS);
daTagz.setAttribute('onclick', pgEdNr);
}
}
}}}}
//Add an event listener on all href tags which include #tab, this will trigger the function to run every time you change tabs.
$('a[href^="#tab"]').on('click', sendMeBackRight(event))
//lets define our function thats run on each event trigger above
function sendMeBackRight(event) {
//below we set our realm variable
var realmName = "unimatrix001"
//gets the hash from the event
var EvName = event.target.hash;
//Below setsup all Regular Expressions required for the whole function
var regexEdPg = new RegExp(/(&z=.+?.{1,10}(?='))/);
var regexP = new RegExp(/(\?a=.+?(?=&))/);
var regexPt = new RegExp(/(\?a=.+?.{1,6})/);
var regexPrd = new RegExp(/(&z=.+?.{1,10})/);
var regexNuR = new RegExp(/(\&nexturl=.+?.{1,100})/);
var regexNeD = new RegExp(/(\&nexturl=.+?.{1,100})(?=')/);
//setup variable for the location
var regLocS = document.location.search;
//below we test 2 situations and set a variable accordingly, we look for the action and make it a variable to apply to the return string.
if (regexP.test(regLocS) !== null) {
var regRedV = regLocS.match(regexP)[0];}
if (typeof regRedV === 'undefined') {
if (regexPt.test(regLocS) !== null) {
var regRedV = regLocS.match(regexPt)[0];}}
if (typeof regRedV !== undefined) {
//Only if the action type is found and set to variable do we move on to encode and build the next url string to be applied to all href tags in scope as well as onclick event for edit record buttons. does apply to new records but gets overwritten by the onclick function - you can write your own handler for this if you like.
if (regRedV !== null) {
var conChe = encodeURIComponent(EvName);
var conChD = encodeURIComponent(regRedV);
//Below is the literal block to build our return path
var lstVisResSS = '&nexturl=https%3A%2F%2F${realmName}}.quickbase.com%2Fdb%2F${gDBID}${conChD}%26rid%3D${kRid}${conChe}';
//set a variable with selector to obtain then loop through each add href tag in the form that contains text 'Add' and the class 'vibrant', just add a code block for other URLs like save and close etc for edit forms back to same tab in view record and so on.
var daTagz = $("a:contains('Add')[class='Vibrant']");
let vibUrlLen = $("a:contains('Add')[class='Vibrant']").length;
for (let i = 0; i < vibUrlLen; i++) {
var resToPro = "";
//if the href tag includes the z redirect we strip it and add the current tab info
if (daTagz.href.includes("&z=")) {
//using regexp replace the z with the nexturl
resToPro = daTagz.href.replace(regexPrd,lstVisResSS);
//apply the attribute to the element
daTagz.setAttribute('href', resToPro);
} else if (daTagz.href.includes("&nexturl=")) {
//this updates previously set urls with the latest tab
resToPro = daTagz.href.replace(regexNuR,lstVisResSS);
daTagz.setAttribute('href', resToPro);
//the below block similar to above handles onclick href in add and edit screens, remember it works for edit, for add you will need to extend to handle add or remove it from scope only in this situation.
} else if (typeof daTagz.attributes.onclick !== 'undefined') {
var edPgVa = daTagz.attributes.onclick.value;
if (regexEdPg.test(edPgVa) !== false) {
var pgEdVa = edPgVa.replace(regexEdPg,lstVisResSS);
daTagz.setAttribute('onclick', pgEdVa);
} else if(regexNeD.test(edPgVa) !== false) {
var pgEdNr = edPgVa.replace(regexNeD,lstVisResSS);
daTagz.setAttribute('onclick', pgEdNr);
}
}
}}}}