User roles are very important with app building, but they can be tricky, especially for those new to Knack database apps. Here I show you how I approach building and managing user roles.
If you are a fan of building great apps with Knack, please click the Subscribe button to join my channel, and ring the bell to receive notices on all my new instructional videos. Thanks!
hey Dave Parish here at Knack Buildersuh I got a video a little different onetoday but umhere's the topic how I approach userroles user rules are a little complex uhand as an Insider how this sort of cameup uh there's a number of usprofessional mag builders that are in agroupand we get together periodically andtalk about all kinds of stuff sometimesfolks in Mac aren't there giving us aheads up on what's going down last weekwe had one of these Zoom meetings Ithink in Boston uh kind of topic of userroleswe all agreed there they can be a littleweird it's like we're all kind of typerbut a couple really well respectedBuilders uh mention how they approach itand it's completely different than how Iapproach it I'm like that's not how I doit and a couple otheruh again very well respected Builders doit the exact opposite and this has to dowith how you use accounts versus the subaccounts of the specific user rulesum I'm going to jump into this uh andI'll be right back thanks[Music]okay let's just jump into Lowdown on howI approach user rules and I mentionedthere's another approach we've all beenaroundthe user the account itselfand I'm gonna throw this in my fellow arequest as my fellow YouTuber Carl homefrom the UK he's an account guyumonce you do a video telling us how youapproach it umbecause I don't know what you do reallyat all I just know what I do and as anaside on this too I don't remember andI've been building for several years Idon't remember how they learned how todo thisuh I think it was trial and error uhKnack does have a document and userrolls and it's it's pretty goodum it tells you all the basics thoughdoesn't really get into all the weirdsituations you can run into and itdoesn't give different approachesum so I'm gonna just here's what I'mgonna do I'm going to call up an app nowfirst I'm going to say this I'm going tohere's a net but I'm gonna go to myaccountumand my shared ad okay in my account Ithink I have 107 well over 100 ads it'sa lot of that apps none of all thesehave user rows most of them doand some of them just have one user rolewhich is a lot more straightforward uhbut when you're dealing with multipleuser rules these different approachesreally come into play I'm just going toshow you what I do now let me go to theapp that's an example of this uhokay this is for here's the live webit's forumwhat I think an NGO they get money fromthe governmentand what they do is recruit on thisparticular program recruitsuh Farmers from all over the U.S andthen they send the farmers to all thesedifferent countries in Africa and theyteacheverything from marketing of a productto how to efficiently run a beekeepingoperation to whatever all differenttypes of Agriculture these volunteerFarmers go over there and teach it andthey have to report since the governmentgiven the money they have to report onall kinds of things that they're doing Iwon't give them the details of that appumlet's go to the Builderplease render hereokaythis stuff for this conversation doesn'tmatter whatsoever here's how I approachit I'm going to make this a littlebiggerzoom inI'll do it once more and zoom inaccounts now we have three differenttypes of user roles one there's avolunteer that can go to the website ofthis organization say I want tovolunteer create an account and startanswering a bunch of questions aboutthemselves now they're available to beselected by another part of theorganization headquarters is inWashington DC these are the people thatcan see everything and do everythinguh field offices are in Mali or in uhZimbabwe all over a bunch of differentcountries andin Africa where they're deploying thisthing out to and field offices just seetheir stuff typical type of thing thiscould be sales person sales manageradmin right it's all the same dealum now for accounts if all those appsare done I've never once had anythingother than the standardumfields that come with this it's justsort of the backbone of something uhit's related to these I put variableinformation and this volunteer is areally good examplethe volunteer they have their regularstuff the name the password the statusthat sort of stuff but now if you're thevolunteer here's a bunch of informationwe collect from them I won't go into allother stuff but you can see that they'reanswering a ton of different stuff aboutthat it's only for the bottoms here I'mnot sure how you do that if you put inaccounts if you had everything centeraround accountsI guess if if different user rules firstof all you might have something thatsays type of account and it could benamed these user roles I'm not sure I'mnot going to get into trying tospeculate how the account approach Worksuh well Marcel I'll just go in detail ofhow this looks but you could have awhole bunch of variable informationthat's about these and only use it whenit's appropriatefield officeum I have all the boilerplate stuff thefield office by its Nature has to beconnected to a country so when you'recreating their views they only show uhRecords related to the logged in userscountry and then it does that for younow I do this a number of times if it'slike even admin I'll do it too I havesomething here that says what they cansee in this case we have uh here thisisn't a quick aside this could beanother video from Builders I I did thisand this particular Builder likes to goand do things on their own I can tellright away they did this and I haven'theard from it yet they have amp passportand passport this and passportdoesn't have a space in front of it thisone does so medical has a space I didnot do that I guarantee you I didn't dothatum but I'm going to go back to my pointhere I often have something but they cansee or the level of permission so Idon't have to you know some of theadmins don't we don't want them to docertain things they're like afull-fledged I don't have to create afull another user around there I just Ijust um limit to have a a field that isa yes or no or whatever and then whenthey try to access a page that theydon't have access to the same admin thatall of them and the full applicant hasaccess to but they try to based on thepage ruleum they've got to hide it or a messagesays you don't have access that isfinancial information or you don't haveaccess to uh social security number thattype of thing regardless that's how Ihandle that and this headquarters one isquite the same uh now there's other andlots of these are different variableinformation this one just happens tohave a little bit the point is I putvariable information here not inaccounts and you go to the pages this ishow I always do these I'm gonna look atthis I'm going to say one thing heremade myself as a builder multiple userroles don't worry about this library andthis indicator things these are a littledifferent put them off the sitethree user rules field office VolunteerHQ I made myself multiple user rolesit's sort of a unrealistic state butwhen you're building I like to be ableto toggle back and forth and see what'sgoing on instead of having to log in andout or have multiple different browsersopen with sessions goingum now when you do that this can comeinto play a number of ways I don't knowwhat I'm talking about when you're doingpage rules or or filtering or a numberof things and you saythis is this user room well you mighthave changed that this containsum but that's a whole other topic tooum so how do I build it out again thisLibrary indicator setup don't worryabout these every user role uh or thepages sideis grouped completely around their userof field office all the content for thefield office it's here here and herehereuh sometimes I create special Pageswhere there can share content like adetail page or something and uh I didanother video on that so you don't haveto remake everything there's lots ofefficient ways to do that um and againI'm not going to get into it alsovolunteer that says all the volunteerstuff just volunteer and same with HQnow a couple of things that can get alittle weird here too I want to mentionthere's probably a lot more I'm going tomentioned couple uh one if you do wantpeople there's a lot of use cases wherethat you might want them to be more thanone uh user role and how I approach ithereum and usually if you just go to thatset you have a man infuser sectionyou'll go toyou want them to be a new user role yougo to that user role you try to add themit's going to say hey this personalready exists you can't add themum and you have to have a process forthat what you have to do is go wherethey are originally let's say they werea field office originally and you wantto be a headquarter also you'd have togo to your manifuzers go to the fieldoffice and then be able to select userrules and then add this to thatthat always is a little confusing to meuh I found a super smooth process for itand it's a little more confusing to myclients but where you work it out nowsomething that uh Julian brought up theother dayI've never run into but it's a reallygood point I don't have a good answerwhat if someone was a field or avolunteerlet's just say this and they somehowbecame a field office they they werehired and now their field officeumand you want here's the point if theychange roles in there you want them tostill use the same email address thatexample I gave may not apply to thatif you changed their role becausethey've moved on to something elseyou don't want to get rid of them in thewhere they were originally becauseyou'll lose a bunch of historic stuffabout them at any place they wereassociated with an activity or they area Time stamped and captured who did anactionI've never run into that and being aproblem I'm probably lucky because itseemed like that could happen and I andthe way Julian talked about it umhe's got a solution for that but uh I'llmove on or that's about all I gotactually if you like this uh Iappreciate it thanks