Forum Discussion
PhillipDennis
9 years agoQrew Cadet
A third approach would be to use Javascript. This is the most powerful and flexible way to do it, but it takes some technical know-how. If you use Dan Diebolt's Image Onload technique to load a Javascript file whenever your form is opened, you can use simple jQuery to remove options easily based on user roles.
You can find out all the app's roles and the way they're represented numerically by looking at the source HTML of any QuickBase form. Search for roleinfo. The roles the current user is assigned to are held in a global variable called gReqUserRoleIDs.
Let's imagine you want to remove Item C from the dropdown for Field ID# 6 for anyone in the Assistant role. You learn from the HTML of a form that the Assistant role has a numerical value of 20. Write a few lines of Javascript like the following and save it as a code page:
You can find out all the app's roles and the way they're represented numerically by looking at the source HTML of any QuickBase form. Search for roleinfo. The roles the current user is assigned to are held in a global variable called gReqUserRoleIDs.
Let's imagine you want to remove Item C from the dropdown for Field ID# 6 for anyone in the Assistant role. You learn from the HTML of a form that the Assistant role has a numerical value of 20. Write a few lines of Javascript like the following and save it as a code page:
(function() {Next, create a formula text field that will get a Javascript file using the Image Onload technique (if you're not familiar with this, just do a search for it). Add the field to your form, and Bob's your uncle. If a user opens the form who has role 20, Item C will be removed from the dropdown for Field ID# 6.
// check to see if the current user is in the Assistant role, number 20
if (gReqUserRoleIDs.search("20") !== -1) { // string.search() returns -1 if the search term isn't found, meaning, in this case, that the user is in role 20
$("select#_fid_6 option:contains('Item C')").remove();
}
})();
GauravSharma3
9 years agoQrew Commander
Hi Phillip,
Thank you for sharing this here. I will try this in one of my scenarios. :)
Thanks,
Gaurav
Thank you for sharing this here. I will try this in one of my scenarios. :)
Thanks,
Gaurav