+ Start a Discussion

Superbadge - Security

I'm trying to get the step -2 and while running the supplied Apex Test, 
Getting below error 

Method NamehugYourMother
Error MessageSystem.QueryException: List has no rows for assignment to SObject
Stack TraceClass.sb_security.BeAwesome.createUser: line 89, column 1
Class.sb_security.BeAwesome.setup: line 81, column 1

I have created the records owned by Samantha as mentioned and also created sharing rule for Project managers.
Can someone please help ?
Nikhil Jaitly 8Nikhil Jaitly 8

Were you able to get this resolved ?

Nikhil Jaitly 8Nikhil Jaitly 8
Also, when you say you have created Sharing Rules for Project Managers, you mean you have created a Public Group for Project Managers and then shared all the Opps with the mentioned criteria with that Group, as we can't use Roles as per the conditions given.

Nikhil, Thanks for responding.
Yes, I have the Opportunity   OWD as Private and then created sharing rules with given criteria to share with public groups   (Opportunity: TypeEQUALSExisting Customer - Upgrade) AND (Opportunity: Stage EQUALSClosed Won)

Also, my sharing rules seem to be correct.
Because when I deleted the sharing rules and checked challange I got the error message complaining about "sharing rules"
Then, when I fixed the sharing rules,  I get the error saying "The unit tests in the managed package have not passed successfully. Make sure you run all test in your org before checking this section. Ensure that they all pass."

When I ran the units test I get the message which I posted in original thread ( 0/1 Test methods passed).
I have also tried re-install of the managed package.

Thanks again for your help!
Hi all,

I dont understand how can we assign permission to a user which is not yet been created, in your case you have shared opportunities with public group but it is not been assingned to project managers.
User-added image
there is something else we are not getting. kindly help if someone finds the solution.

and correct me if i got it wrong.

Igor M.Igor M.
Arvindyadav, you need to make sure that you have opportunities set to private for org wide defaults under sharing settings. Once that's set you need to create a new sharing rule specific to project managers. This rule must be criteria based. Use the criteria listed in the description under "Organizational Security Requirements." This should resolve your issue.
As for the issue Trail-Runner has started here, I'm also running into this issue and have no idea what to do here. Looking at it, it seems as if it's trying to create a user, but it can't. Perhaps it's trying to create and associate a user to a license that's already used up? The only thing I can conclude is that we need more information about what's happening here in order to figure this out.
Igor M.Igor M.
Has anyone had any luck with this? I've looked through the logs and I'm starting to get the feeling that it's an issue with the beta package that Salesforce provides.
Brian Gardner 1Brian Gardner 1
I'm at the same junction as both Igor and Trail-Runner and am at a loss as to how to address this error, especially since there is nothing specific in the error message to assist in knowing what the error actually is. 
The error is giving you a hint.  You need a sharing rule, and need to figure out who to give that rule to.
Also, the last requirement gives you the hint about the sharing rule and the group to give it to.

Use the name Project Managers when naming any security property related to PMs.
Ankita PatelAnkita Patel
is this possible to solve the challenge with 2 salesforce licence or I need more ?
as for group users and all I need total 3-4 users to fulfill the condition.
or is it possible with 2 users only ?
Martin HumpolecMartin Humpolec
see this thread https://developer.salesforce.com/forums/?id=906F0000000kEGAIA2
I was able to clear this stage with the following steps (and, I am sure most of these steps you all are following):

1. OWD settings for Opportunity object is 'Private'
2. Created public group as 'Project Managers' for Project Manager related requirements.
3. Setup Profiles and Roles for Field Sales User, Inside Sales User, and Sales Executive User
4. Created one criteria based sharing rules for Opportunity:
Criteria: (Opportunity: TypeEQUALSExisting Customer - Upgrade) AND (Opportunity: StageEQUALSClosed Won)
Shared with: Group: Project Managers
Access level: Read Only

5. Then, created another sharing rule for Opportunity (this one I created only after unsuccessful run of the test cases). This sharing rule is owner based, with the following details:
Criteria: Owner in All Internal Users
Shared with: Role: Inside Sales
Access level: Read/Write

These steps should be enough to complete the stage-2.
Ray J.Ray J.
I was getting similar errors. This is how I resolved it.
1: Created a public group "Project Managers"
2: Added "Carla Rodriguez" to the "Project Managers" group
3: Created the following two opportunity Sharing Rules (image attached)

First Rule Name = Project Management
(Opportunity: Type = Existing Customer - Upgrade) AND (Opportunity: Stage=Closed Won)
Share with
Group: Project Managers
Opportunity Access
Read Only
Second Rule Name = Share with inside sales
Owner in Role: Field SalesRole:
Share with
Inside Sales
Opportunity Access
Note: Make sure OWD for opportunity is set as "Private

Opportunity Sharing Rules
Ray J.Ray J.
Follow the steps in this article (https://force.desk.com/customer/en/portal/articles/2710899-installing-a-package-or-app-to-complete-a-trailhead-challenge?b_id=13478)
Derek Bennett 5Derek Bennett 5
Hello everyone,

I was able to pass 1/2 of the apex test challenge. Can anyone help and advise why I cant pass the entire challeenge?

Here is the error code I receive when trying to run the test:
System.AssertException: Assertion Failed: Inside Sales users should be able to read all Opportunities but the test did not find all records. #sadtrombone: Expected: 3, Actual: 2

Any advice?
Derek Bennett 5Derek Bennett 5
I figured out why my apex test only passed 1/2 of the test. Once I gave the inside sales user the View All permission for opportunities I immediatley passed both apex test and completed challenge 2User-added image
Akeel WaniAkeel Wani
Hello Guys. I was just finishing the superbadge and got the below error. SCratched my had for a long time but no go. I tried to change the opportunity owner as well but no go. Its throwing error   Error: Transfer Requires Read.. Can anyone please help User-added imageUser-added image
Dillon Moore MooreDillon Moore Moore
Hello all,
I am having issues downloading the trailhead security superbadge managed package on a new playground.  Everytime I click the link it wants me to login and takes me to my main playground.  I have everything taken care of for step 2 but obviously the apex tests wont run since i dont have the package installed.  Please help me so i can finally finish this
samyuktha reddy etikayalasamyuktha reddy etikayala
Hi Team,

As  have started doing Security Specialist Superbadge, where have been strucked in middle, am getting an error.Am not finding the path to resolve.
If someone helps that would be great Apprceiable In Advance Thanks.

User-added image

Thanks and Regards,
Taylor ChinTaylor Chin
So I keep seeing mentions to the roles field sales and inside sales in these comments. The only mention to these im seeing is a small tree diagram wiht sales executive at the top and field sales and inside sales connected to it. But I dont know where in the tree created by downloading the superbadge package im supposed to put these roles.

And the description just say s there are three core teams in GenZ's main sales organizational structure. So do I just want to make sales executive report to CEO and field sales and inside sales report to the sales executive? Also do I need to create users for the names shown in the organizational overview?
Taylor ChinTaylor Chin
I have the hug your mother test passing but for the HelpAStranger class im getting the error that Inside Sales should be able to update Acc Class.sb_security.BeAwesome.helpAStranger line 46 column 1.
Im unsure of how to make it so inside sales can update account as inside sales can view edit and create accounts.
Armando Prieto TrianoArmando Prieto Triano
In my case, uninstalling Trailhead Superbadge - Security package from Developer edition instance, and reinstalling in Playground
Haihong MaHaihong Ma
In my case, I run out of Salesforce license that I cannot assign users in this case the proper role & Profile. 
Salesforce is not available in my User License list. What can I do? I'm on Dev edition. 
Pratiksha ChauhanPratiksha Chauhan
I was also facing the issue to pass this challenge due to test class failed , in my case it was the spelling error of role Sales Executive , i wrote it Sales Executives and after correction it worked for me. Please make sure about the spellings before passing this challenge. I hope it would help.

Thanks and Regards,
Pratiksha Chauhan
Ignacio VelázquezIgnacio Velázquez
The answer of MaxWorld helped me to pass one test method. It is important to create an opportunity sharing rule that has the following:
Rule type: Based on record owner
Opportunity owned by members of Public Groups | All internal users
Share with: Role Inside Sales Opportunity access: Access Read/Write
Before I created that sharing rule I was facing the the following error (This is because you might have an opportunity sharing rule that share from field sales to inside sales; i.e: role to role).
So I deleted that and created a new one as the user Maxworld suggests
User-added image

Also, NOTE that you must have the three roles created, I was missing the Sales Executive role, then run the test and the other test method passed.
Stay purposeful!
Samantha Cordero 581Samantha Cordero 581

hi, i am doing Security Specialist 2nd challange and i got an error in apex test execution can anyone please rectify my error

error message :-System.AssertException: Assertion Failed: Field Sales users should not be able to read Opportunities owned by someone else. However, the test returned records not owned by the user. #sadtrombone: Expected: 1, Actual: 3
Samantha Cordero 581Samantha Cordero 581
User-added image

keep getting this error  Security Specialist 2nd challenge
1)  3 profiles created

  • Inside Sales User
  • Sales Executive User
  • Field Sales users

2) 3 Roles Created

  • Sales Executive reporting to CEO
  • Field Sales reporting to Sales Executive
  • Inside Sales reporting to Sales Executive

3) 2 sharing Rules created

Field Sales user Samantha Created 2 opportunity 

and after running the Apex Test Execution it does not pass Please HELP