I made a MERN stack but I have a problem with making roles for users. Any solutions? - reactjs

So I thought that I want to make roles for users, e.g Role1 can choose from AutoSearch field an employee and click the button with the possibility of writing a comment. Role2 can click the Comment button and click the 'Mechanic Tools' button. Role3 can click every button + a link from PrivateRoute which is 'Register'(adding a new employee to the database). For Role1 as you can realize it's impossible to click the Mechanic Tools button but its role can see the result of it. Additionally, the whole app has to keep the state of clicked buttons(buttons are like ON/OFF). I assume that I have to make those buttons sending state to MongoDB but I have no clue how to start with that roles thing.
I was trying to make that in MongoDB obviously but I didn't mean the database accessibility but the possibility of clicking each element in-app.
I mean these yellow buttons + the text field under the tire. Sorry that I dont write code but I have it in 3 different files and you might not understand what I mean.
https://gyazo.com/f604257b88efb04c64d04d73113e0125
I expect the possibility of logging in(I can do it now) as a user with a role assigned to its account with permissions.

Related

Autopopulate a field in a form based on what user is logged in

I've created an access database using access 2007 for one of the teams I work with and I'm fairly new to access so would like some help. The database is being used to log jobs for engineers so I have a login system where a user selects their name from a drop down and enters their password, and depending on their access levels they get directed to their own user menus etc. Now what I would like is once the user has logged in they will click on the job sheet button will then direct them to a list of jobs raised from here they click on new and then a pop of the Job Sheet where they can enter details from the call pops up what i want is in this job sheet for their name to auto-populate in the field labelled user, how do I get the user who has logged in their name to just auto populate in the field once they have accessed it.
You might want to check out the "OnLoad" property of the form. Go to the properties section of the job sheet and click on its "on load" event. Select VBA code. Type the following:-
me.fieldname = [Forms]![FirstFormWhereLoginDropdownPresent].DropDownName.Value
Hope this helps

Salesforce field level access determined by third variable

For the contacts object, I have a custom checkbox which represents whether the contact owner wants the contact information (email and phone) to be visible. Most of our contacts will be completely visible to everyone. However, for a few contacts, we want them to be visible but their contact information needs to be hidden to everyone except for the owner.
Is there a way to set field-level access dependent on another variable? Could you create a workflow to redirect to another page layout if the contact information is visible? If so, can you restrict objects to certain field layouts depending on whether or not you are the record owner? And would would the contact information for "hidden contacts" still show up in reports?
Redirects, custom Visualforce view page etc hacks are all nice and shiny until you realize people will be able to pull data they want via some reports, list views, Outlook integration, mobile apps etc ;)
There's no straightforward answer because field visibility is really "all or nothing" (by Profiles & Permission Sets). Owner/Role-related stuff will help you only if you'd store data in some new related objects.
Another option - Store public part in Leads (public read only for example) and sensitive part - in Contacts (private)? Some lookup to link the 2, maybe a trigger when new Contact is created and you're good to go.
Last but not least - have a look at https://salesforce.stackexchange.com/questions/777/can-i-grant-different-field-level-security-based-on-record-ownership for some ideas.
If I understood correctly (My english...) You could create a new RecordType and a new customized page layout without this fields assigned to it, then you have to create a WFR that change the Recordtype when the cheked field becomes true.
I'm assuming that you know how you have to give permissions to this new Recordtype...etc
Hope this helps.

Website "you can do this" script

I want to create a training path for new users accessing my site. This training path must display info bubbles showing what you can do on every page, but only the first time you access it.
So, for example, if a user enters a page where there's an edit button an info box should appear next to the edit button telling the user that he can edit that page.
I will create the script myself, I just want to know what's the best method to check if the user has already seen that box or not. I was thinking about storing in database a boolean value for each info box which will be set to true if the user has seen the box. To save some queries from the DB I think I can also store the same values in localStorage or in Cookies.
What is the best practice for creating user training paths for a website?
The way I suggest is to store user id (ip or username ? ) and a bit value for each bubble like you say.
PS: for your script you can use this:
http://www.maxvergelli.com/jquery-bubble-popup/documentation/
Jérôme

Display Alert box through the trigger - salesforce

Is it possible to display an alert message (not error message) through a trigger? I have written a trigger that checks for duplicate accounts in the system. The trigger at the moment gives an error message to the user telling that there is a duplicate account. But, if the user changes the value of a field "Is record near to duplicate?" to YES, the trigger allows the user to save the record.
But, I want to display the error message in an alert pop up box like "Account with this Name exists,are you sure you want to continue" and then user clicks Yes and the record gets created. Any thoughts on how I can do this. My code is below:
for(Account account: System.Trigger.New)
{
if(accountMap.containsKey(account.Physical_Street__c)==accountMap2.containsKey(account.Phone))
if(accountMap.containsKey(account.Physical_Street__c)==accountMap3.containsKey(account.Name))
if(account.Is_record_near_to_duplicate__c.equals('No'))
{
account.addError('Account with this Name,Street and Phone Number already exists. If you still wish to create the agency change the value of field "Is Record Near To Duplicate" to YES');
}
}
If you really need an alert box then you could create a custom javascript button that uses the ajax toolkit to replace the standard save button.
However, as Baxter said you are getting pretty far from standard salesforce look and feel. I would recommend instead to add an error on the checkbox field instead of the object so it is clear to the user what they need to select.
if(account.Is_record_near_to_duplicate__c.equals('No'))
{
account.Is_record_near_to_duplicate__c.addError('Agency with this Name, Physical Street and Phone Number already exists. If you still wish to create the agency change the value of field "Is Record Near To Duplicate" to YES');
}
Unless you write a custom visualforce page that processes the error message and then displays it as a popup there's no way to do this.
If you wanted the alert to modify the data you may look at using the ajax api to set the Is_record_near_to_duplicate__c field to 'Yes' but either way you're getting pretty far from the standard functionality and interface with this.
It is not straight forward to implement a pop-up alert for a trigger error, and pop-ups went out-of-fashion a long time ago. If you are going through the hassle, you might as well implement a custom soultion on a VF page.
Throw a custom exception(for dupe accounts) from the trigger, and catch it in your controller. When you catch this exception, you can dynamically displayed section on the page which asks the user to confirm his/her action. When the user confirms the action, the page will do the rest.
Hope this makes sense!
Anup

How can I set the approvers for all steps in an approval process?

I have an approval process with three steps, all of which are set to Assigned Approver = Manually Chosen. When the user submits the record for approval, I'd like to have Apex code determine who the three approvers are. However, I don't see a way to hook into the approve request submission.
If I submit the approval with Apex Using Approval.process(), I can set the initial (and only the initial) approver with ProcessSubmitRequest.setNextApproverIds(). This call leads you to believe you can specify multiple approvers since it takes an array of Ids, but the array can only have 1 element, or else runtime a error occurs.
Once I know what the first approver's response is, I can use Apex to submit her response and, again, set the immediately next approver by passing a ProcessWorkitemRequest instance to Approval.process(). An important note here is that the approver must not approve via the standard UI. Instead, they must do something that invokes the Apex code so that we can set who the next approve should be. A trigger on the object under review, or a custom button + VF page could be used to invoke the Apex.
My main question is, how can I make sure that the user does not use the standard approval buttons? They appear in the Approvals related list and on the salesforce home screen. It may be in other places as well. Again, if they use the standard submit and approve buttons, I don't have any way to hook in to set the next approver.
We ran into a similar issue a while back and solved it by creating custom lookup fields to certain users. For example, if we wanted to route an approval request up to a Director and then a VP, we added Director__c and MarketVP__c fields to the object. These fields were populated in code by climbing the role hierarchy whenever a request was submitted. Our approval process's steps then chose who the assignee would be based on the values in these fields (first step would be assigned to Related User: Director and the second step would be assigned to Related User: Market VP, etc.).
To get around the standard approval button issue (we had other reasons for hiding it), we just hid that from their homepage layouts and built our own VF page and included it in a custom homepage component. This component functioned as an inbox with links to any records that were pending the user's approval. All user interaction with the approval objects was handled through other VF pages with their own Approve and Reject buttons. I don't know if the objects you're submitting to the approval process even use VF pages, so this may not be feasible for your situation.
A lot of customization for something that shouldn't need it, I know. Might not be the answer you're looking for, but hopefully it's some food for thought.

Resources