Hot answers tagged

5 votes
Accepted

SOQL query in .js file in LWC

No, you can't write a SOQL in the js file, but if the SOQL would have been something like "SELECT fields FROM object WHERE Id = 'xxx'" or "SELECT fields FROM object WHERE Id IN ...
user avatar
  • 3,738
4 votes

How to run an Async SOQL query other than via Workbench

Based on Running Async SOQL Queries, it should be possible to obtain via callout, as it lists a Request URI: https://yourInstance.salesforce.com/services/data/v38.0/async-queries/ The sample response ...
user avatar
  • 144k
4 votes
Accepted

Query for all Custom Apex Web Services "@RestResource"

There is no method for looking at managed, hidden code (unless they publish it elsewhere). Regardless, the proper tool for the job is SOSL, not SOQL, as the former can search the text of the class ...
user avatar
  • 144k
4 votes
Accepted

how to select all AccountId of the table X that is not in the table Y?

It might not work with CampaignMember, but the mechanisms you need for this are called table joins and anti-joins. It would look something like: SELECT Id FROM Account WHERE Id IN (SELECT AccountId ...
user avatar
  • 144k
3 votes
Accepted

Apex Error "Too Many SOQL Queries" with Trigger on ContentDocumentLink

For each content version getting inserted, Salesforce creates a Content document link record in backend on the running user, which surprisingly triggers Content Document link trigger one by one. This ...
user avatar
3 votes

How can I query records that have a created date older than 1 hour

I think the date initialization and the conditions are a little bit different, If we debug the times we could find that System.Now() = 2022-07-15 05:56:32 System.Now().addHours(1) = ...
user avatar
3 votes

SOQL select columns with names that contain specific word

No, there is not. SOQL and SOSL generally demand that you explicitly list out all of the fields that you wish to query. FIELDS([ALL|CUSTOM|STANDARD]), and the automatic inclusion of the Id field (and ...
user avatar
  • 49.5k
2 votes
Accepted

SOQL select columns with names that contain specific word

Is there an SOQL command that could help me to select all the fields in a specific object that contains the word Location No. However, you can build a dynamic SOQL statement: String[] fields = new ...
user avatar
  • 438k
2 votes

SOQL query and record Id in update DML. Did behaviour change?

Even the first snippet of code will not throw an error because you are updating the record and we just need id of the record for updating and you can update any field in the Account irrespective of ...
user avatar
1 vote
Accepted

Error in Dynamic SOQL when binding a variable

Let's say your class is like this: public inherited sharing class MyFirstBatch implements Database.Batchable<SObject> { String query; public MyFirstBatch(objName, fromDate, toDate) {...
user avatar
  • 3,738
1 vote

Testing a batch class where I need to modify System fields?

If you Enable the 'Create Audit Fields' permission, make sure your user has this permission assigned (perhaps by Permission Set), then perform an insert DML operation, you can set the dates as you ...
user avatar
  • 438k
1 vote
Accepted

Trying to build group hierarchy to display public groups and which public groups they inherit

As far as I'm aware, there's no extra limits placed on subquery filters. You'll still be subjected to the 50k row limit for the records returned, and you will likely be subject to the selective query ...
user avatar
  • 438k
1 vote

How to 2nd highest salary, we have repeated values

In Apex you can use a Set to eliminate duplicates and then use the sort method of List: List<Decimal> salaries = new List<Decimal>{ 18000, 17000, 18000, 16000, 18000 }; ...
user avatar
  • 130k
1 vote

Different results executing in Anonymous Window and in Einstein Bot

I solved my problem add the "without sharing" keyword to my class.
user avatar
1 vote

SOQL select columns with names that contain specific word

No, there isn't one. You can only use FIELDS(ALL), FIELDS(CUSTOM) or FIELD(STANDARD) to fetch all fields or custom fields or standard fields respectively. However, you can query FieldDefinition object ...
user avatar
  • 4,932

Only top scored, non community-wiki answers of a minimum length are eligible