Are you ready for the Salesforce Winter '24 Release?
Check out the full list of new features and updates available in the Winter ’24 Release.
Did you find this helpful?
Help us enhance your experience.
Error ‘List has no rows for assignment to SObject’ in Salesforce CPQ
The error 'List has no rows for assignment to SObject' occurs when an invalid quote process ID exists on the Quote's Quote Process ID field. This field is meant to be populated by a workflow rule. This issue can also occur when the user attempts to reconfigure a Primary Quote without Read access to the associated Opportunity. Lack of access to the Opportunity object throws List has no rows for assignment to SObject' since our code queries for the Primary Quote on that opportunity.
Cookie Consent Manager
General information, required cookies, functional cookies, advertising cookies.
We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings. Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.
Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Rest API FATAL_ERROR System.QueryException: List has no rows for assignment to SObject In Test Class
I'm unable to fix the code and giving the error as "FATAL_ERROR System.QueryException: List has no rows for assignment to SObject " in test class. I have implemented Apex class for rest API but having the issue with test Class. Could you some one help me on this?
See Below apex class code,
Test Class is below
Is I'm missing anything? Thanks in advance for the help..!!!
Well, in your test class you create an account
but in the class under test you search for an account that is a person account and has to have PersonEmail set. As you haven't created a matching account, in the line
there is no result, which creates an Exception.
Always first store all possible results in a list, and then check if there are actual results - you would always never be sure there will be a result.
So, first change the class under test to
and second, do create a matching account in your test class, so that the class under test actually can find a result and work with that.
You must log in to answer this question.
Not the answer you're looking for browse other questions tagged apex unit-test rest-api force.com ..
- The Overflow Blog
- Like Python++ for AI developers
- Being creative with math: The immersive artist who traded a sketchpad for a...
- Featured on Meta
- Alpha test for short survey in banner ad slots starting on week of September...
- What should be next for community events?
Hot Network Questions
- Why does the Psyche Spacecraft use cold gas thrusters?
- Word Implying Lack of Caring Because You're Already (Wrong/Losing/a Failure/Behind/Insignificant)
- How do stars 1 billion times the volume of our sun form and can they become black holes?
- Compute how many are no larger than each item in an array
- Is the luggage trolley essential to get through Platform Nine and Three-Quarters?
- Hidden dots in the center
- Feeling of falling during turbulence
- In countries using Single Transferable Vote, how are voting results presented?
- Map function to list in Mathematica
- Is this classed as a version of jobshop? How shoiuld it be approached?
- Protected Restriction
- Booked Lufthansa Flight + Train, where do I go for baggage reclaim?
- History of right hand rule
- What is the difference between added sugars and natural sugars in processed foods?
- How late were 80-column punched cards relevant?
- How do I intentionally fly into turbulence?
- What was the purpose of the breastplate rings on samurai armor?
- Why are hashSequence and hashPrevouts computed separately?
- Obscure sci-fi illustration book showing speculative alien life forms on other worlds
- Why is Trump's alleged fraud in New York not prosecuted as a criminal offense?
- My husband (her father) jokes/plays in ways my daughter doesn't always find funny, he says he should be able to do it if he wants
- How to move forward after microaggression allegations against my TA
- "bieten" with the meaning of "to ensure"
- What is the meaning of "transformed away" in the following sentence?
- My Developer Account >
- Create Account>
- My Settings>
- All Developer Centers
- Community Cloud
- Einstein Analytics
- Einstein Platform
- Embedded Service SDK for Mobile
- Heroku Developer Center
- Integration and APIs
- Lightning Apps
- Lightning Flow
- Marketing Cloud
- Mobile Developer Center
- Mulesoft Developer Center
- Pardot Developer Center
- Quip Developer Center
- Salesforce DX
- Service Cloud
- Lightning Component Library
- Lightning Design System
- Lightning Aura Components
- All Documentation
- Sample Gallery
- Video Gallery
- Events and Webinars
- Success Stories
- Developer Groups
- Trailhead Resources
- Leading Through Change with Data
- COVID-19 Data Hub
- COVID-19 Global Daily Tracker
- Global Economy Data Track
- Government Data Track
- Healthcare Data Track
- B-Well Together
- Leading Through Change
- Salesforce Care
- AppExchange Resources
- MuleSoft Resources
Don't have an account?
Browse by Topic
- View More Topics
- See All Posts
Welcome to Support!
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
- All Questions
- Unanswered Questions
- Unsolved Questions
- Solved Questions
- Date Posted
- Recent Activity
- Most Popular
Sign in to start a discussion
- This Question
FATAL_ERROR System.QueryException: List has no rows for assignment issue to SObject
ownerUser = [Select Id, UserRoleId from user where UserRoleId IN :lstUser AND Id = :opp.OwnerId];
This is causing me the exception, what is wrong with this?
- May 8, 2019
- May 9, 2019
You need to sign in to do that.
Select a category.