Editing Locked Opportunities - Regional Approval Process - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Mark GrahamMark Graham 

Editing Locked Opportunities - Regional Approval Process

Our org had some work done a few years ago, where the sales managers could not make an opportunity which was not in their designated region.

e.g. someone who operated in the UK, could not make a quote for a company in the USA. The opportunity would lock and it would go to the sales director to unlock and approve / reject. 

This works to a degree, but it has caused issues as the business has grown - some guys now operate globally, yet are based in the UK, so all their opportunities get locked if in Europe etc. I added one user to the approval list, so he can unlock his own global opportunities, but this is very much a short term fix.

How can I take away the approval process for certain users? I have attached a screenshot, I see no mention of users, I dont quite undertsand how it was made. I may looking in the wrong place? 

User-added imageUser-added image
Mary TaglerMary Tagler
You can definitely entry criteria or auto approve opportunities for those users
Mary TaglerMary Tagler
Definitely = define.

Off the top of my head, you can assign those users a custom permission and reference it in your criteria. So if the owner has the custom permission, approve.
Mary TaglerMary Tagler
Here's a link on custom permissions

https://jenwlee.wordpress.com/2016/06/07/using-custom-permissions-in-process-builder/
Mark GrahamMark Graham
Hi Mary 

I had a look in the process builder but I saw no mention of the regional approval stuff at all. I am not sure where the settings are being driven from. Could it be held in apex code somewhere? 
Mary TaglerMary Tagler
Do you have any processes on the opportunity object? It could just be a node. In your sandbox, I'd run this and turn on your debug log to see what is firing. Apex isn't needed to kick off the approval, but that doesn't mean it wasn't used.
Mary TaglerMary Tagler
If so, there should be an Apex trigger on opportunity and a class that handles this use case.
Mark GrahamMark Graham
Sales processes? if so yep, we have two sales processes - one for end users and one for OEM & distributors
Mary TaglerMary Tagler
Sorry, process as in process builder
Mark GrahamMark Graham
We only have one active which emails someone in logiitics to say an order has been won, there are some other non related ones which are inactive. 
Mary TaglerMary Tagler
I made an assumption, are these opportunities automatically submitted for approval? Before process builder, I believe code was the only way to do that. 

Technically, you could change (add to) your approval steps without touching the code using the custom permission setting to identify when it should auto approve for your global submitters.
Mary TaglerMary Tagler
I can mock something up in a half hour of so.
Mark GrahamMark Graham
Yes thats right, Mary! When the guy goes to savr the opportunity, if the setup detects the user is making an Opp for a company outside of their designated area then it locks the opportunity right away and they cant do anything until its unlocked.
Mary TaglerMary Tagler
It could also have been built out in flow. Either way, I'm going to mock something up that will leave that as is, but should allow the global users to get auto-approval.
Mark GrahamMark Graham
Thanks!
 
Mary TaglerMary Tagler
OK, bad news. While I can get the process to auto-approve the records for those with global permissions via the method I suggested, it would auto approve, but not unlock the record, which is key here. The best solution would be to bypass the approval altogether for those with global approval permission and to do that, you need to figure out what is throwing them into the approval. I would check setup and Flows and see if you see any Flows and if any of them pertain to the opportunity. If so, I can help you with that. If it's code, I can't counsel you to simply deactivate or comment out the portion of the code that does that; you would need to get a dev resource who fully understands what you want and what else might get impacted by touching that code. If it is code, I would move this out of code into process builder because it's something you'll be able to decalaratively maintain.

I am going to attach the images below and explain the custom permission because I think you'll need this going forward.

This is the custom permission I created. Basically, pick a name and add a description
User-added image
Create permission set, note its purpose and after you save click on Custom Permissions
User-added image
Assign the custom permission to the permission set
User-added image
Don't foget to then assign that permission set to the global users.

Once done, you can use logic like this to determine whether the user has the custom permission set. What I did here was say if the user doesn't have the custom permission set, send it through to the approvers. Otherwise, if they do, approve. Instead of making that a step, I would probably connect my approval to a process builder and have logic for entering the approval process either contained in the process or in the approval itself as entry criteria.
User-added image
Mark GrahamMark Graham
Thanks very much Mary! There was nothing in flows sadly, but I will check this out and hopefully it will help!! Much appreciated