Salesforce-Platform-Developer-II Practice Test

Salesforce Spring 25 Release
202 Questions

A company has a custom object, Order__c, that has a custom picklist field, Status__c, with values of `˜New', `˜In Progress', or `˜Fulfilled' and a lookup field, Contact__c, to Contact.
Which SOQL query will return a unique list of all the Contact records that have no `˜Fulfilled' Orders?

A. SELECT Id FROM Contact WHERE Id NOT IN (SELECT Id FROM Order__c WHERE Status__c = 'Fulfilled')

B. SELECT Contact__c FROM Order__c WHERE Status__c <> 'Fulfilled'

C. SELECT Id FROM Contact WHERE Id NOT IN (SELECT Contact__c FROM Order__c WHERE Status__c = 'Fulfilled'

D. SELECT Contact__c FROM Order__c WHERE Id NOT IN (SELECT Id FROM Order__c Where Status__c = 'Fulfilled')

C.   SELECT Id FROM Contact WHERE Id NOT IN (SELECT Contact__c FROM Order__c WHERE Status__c = 'Fulfilled'

Explanation:

To find Contacts who do not have any 'Fulfilled' Orders, we need a query that:
1. Starts from the Contact object, since we want a list of unique Contacts.
2. Excludes Contacts who are associated with any Order__c record where Status__c = 'Fulfilled'.
3. Properly handles the subquery structure and relationship fields.

Let’s evaluate each option carefully:

✅ Correct Answer: C.
SELECT Id FROM Contact WHERE Id NOT IN (SELECT Contact__c FROM Order__c WHERE Status__c = 'Fulfilled')

✅ Explanation:
The outer query fetches all Contact IDs.
The subquery gets the list of Contact__c values from Order__c where Status__c = 'Fulfilled'.
The NOT IN ensures that any Contact who has at least one Fulfilled Order is excluded.
The result is a unique list of Contacts who are not involved in any Fulfilled Orders.
This query follows the correct syntax, correctly references the child-to-parent lookup (Contact__c), and applies the filtering on the child object (Order__c), which is the only proper way to identify this condition.

🔗 Reference: Salesforce Docs – Using Subqueries in SOQL

❌ A. SELECT Id FROM Contact WHERE Id NOT IN (SELECT Id FROM Order__c WHERE Status__c = 'Fulfilled')
The subquery returns Order__c IDs, not Contact IDs.
The outer query compares Contact.Id to Order__c.Id — this is invalid and will throw an error or return incorrect results.
Mismatch of ID types in subquery and outer query.

❌ B. SELECT Contact__c FROM Order__c WHERE Status__c <> 'Fulfilled'
This returns Order records, not Contact records.
Also, it doesn't guarantee uniqueness, and doesn’t filter out Contacts who have both Fulfilled and non-Fulfilled orders.
A Contact with both types of Orders would still appear here, which violates the requirement.

❌ D. SELECT Contact__c FROM Order__c WHERE Id NOT IN (SELECT Id FROM Order__c Where Status__c = 'Fulfilled')
This is querying Order__c, not Contact, and filtering based on Order IDs.
It only returns Order records that are not Fulfilled, but does not ensure the Contact doesn't have other Fulfilled Orders.
Also, the result will be Order__c, not a unique list of Contacts.

✅ Final Answer:
C. SELECT Id FROM Contact WHERE Id NOT IN (SELECT Contact__c FROM Order__c WHERE Status__c = 'Fulfilled')
This is the only correct SOQL query that:
Targets the Contact object.
Filters out Contacts who have any Fulfilled Orders.
Returns a unique list of Contact records.

Salesforce-Platform-Developer-II Practice-Test - Home Previous
Page 7 out of 202 Pages