New answers tagged soql
1
vote
Accepted
Correlated Not In Subquery
No, correlated subqueries are not supported. But in Apex you can use the same variable with the case identifier in both queries:
SELECT Id
FROM Task
WHERE Type = 'Case'
AND WhatId = :caseId
AND ...
2
votes
Accepted
SOQL Lib how to test a sub query
To test sub-queries you should use the deserialization mechanism with JSON data (to write on non-writable fields), as described in the documentation:
Sub-Query
To mock a sub-query we need to use ...
0
votes
Getting Distinct Values in SOQL Query
Query the latest StageName from the Opportunity object to use the OpportunityFieldHistory object, which tracks the history of changes for the StageName field. You can use a SOQL query that filters by ...
2
votes
Accepted
Executing SOQL with User Mode and then DML with user Mode causing Exception
My_Rule__c appears to be a master-detail relationship field with reparenting disabled. For some reason, supplying the same value as what is already in the field still causes this error, because the ...
1
vote
Accepted
How to deactivate all flows via sf cli
ah I found appropriate syntax
sf data update record --json --use-tooling-api --target-org $targetOrgAlias --sobject FlowDefinition --record-id $flowId --values "Metadata='{\"...
1
vote
Dynamic SOQL Error: Unexpected Token ':' - I have searched for two days, what could I be missing?
You can use String join to fix the issue.
String selectList = String.join(fields,',');
String soqlQuery = 'SELECT ' + selectList + ' the rest of the query... ';
0
votes
Using SOQL to pull records where conditions can be AND but also OR
I'll simplify your query to be clearer. I used A, B, C and D to differentiate your criterias.
SELECT MY_FIELDS from MY_OBJECT WHERE (A AND B) OR (C AND D)
Now, assuming that this query can not ...
0
votes
Using SOQL to pull records where conditions can be AND but also OR
I'd hard code two queries: one with the OR and one with the AND.
Alternatively you could only execute the OR one and check if the AND condition is true as you loop over the OR results using Apex logic....
1
vote
Accepted
SOQL Count Distinct Accounts based on MIN Approved Date
You are correct that SOQL does not support subqueries in the FROM clause, unlike SQL. However, you can still achieve your desired result by using a different approach.
You can use an aggregate query ...
0
votes
PicklistValueInfo does not returns Custom object's picklist records but only returns standard object's picklist records
Or in one step...
SELECT Value,Label,IsActive
FROM PicklistValueInfo
WHERE EntityParticle.EntityDefinition.QualifiedApiName = 'Client_Master__c'
AND EntityParticle.QualifiedApiName = 'Status__c'
0
votes
SOQL Nulls Last with Orderby Picklist field doesn't work
You can try creating a text type formula field, with the name PriorityText__c like this: TEXT(Priority__c)
Then you change your Query for this:
SELECT Id, ContactId, LeadId, Status, Priority_c, ...
Top 50 recent answers are included
Related Tags
soql × 5884apex × 2792
query × 648
visualforce × 405
trigger × 374
dynamic-soql × 303
governorlimits × 229
relationships × 159
batch × 143
rest-api × 140
unit-test × 118
community × 112
list × 106
sosl × 103
aggregate × 95
custom-object × 86
map × 79
account × 72
api × 71
date × 66
lookup × 61
sobject × 59
opportunity × 58
loop × 58
aggregateresult × 57