Questions tagged [soql]

Salesforce Object Query Language (SOQL), modeled on SQL, for accessing information saved in the Salesforce database.

Filter by
Sorted by
Tagged with
0
votes
1answer
9 views

Query Activities associated with Contacts

I am building a lightning component on Account that takes the Account ID and returns the contacts and the most recent task associated with it. @AuraEnabled public static list<Contact> ...
0
votes
2answers
23 views

Querying for users in a a Role based on Role Id instead of RoleName or DeveloperName

List<User> usrlst = [SELECT Id FROM User WHERE UserRole.DeveloperName LIKE : '%Customer_Support_Representative%' and IsActive = True]; The problem with this is that we changed the name of the ...
0
votes
1answer
13 views

ActivityHistory Object is not accessible for the Profile Users

I am trying to put a lightning component to show all the past activities associated with the Contact. It is my understanding that if the user has access to the Contact then he should be able to see ...
1
vote
1answer
34 views

SOQL Performance with multiple lookups

I have a search query in my component that shortly will need to support more than one lookup field where only one would be filled on the certain object. For now the query looks as follows: SELECT ...
0
votes
0answers
19 views

SOQL to find all the recordTypes assigned to a profile or a user

Need to show all the record types created on Task object assigned to the logged-in user. I did not find any relation between the RecordType object and profile which can give me the details. Tried ...
0
votes
2answers
23 views

query all users for associated groups and queues [closed]

Is there any way we can query all users for associated groups and queues For example, I have 200 users and I want to check their assigned groups and queues. Is there any query that I can run on ...
0
votes
1answer
16 views

Retrieve Owner Name from the Sub Query to use in Datatable

I am trying to get the Owner Name of the Task that is associated with the contact and display it in the lightning component. The Sub Query for retrieving the Tasks associated with contact is below ...
0
votes
1answer
16 views

Get all the apex classes which a profile has access in Enabled Apex Class Access

I have done lot of searches but not get any conclusive thing to full fill my requirement.My requirement is to fetch all the apex classes which a profile has access in Enable Apex Class Access and then ...
1
vote
1answer
31 views

SOQL Sub Query to retrieve the Owner Name

I am trying to retrieve the Tasks associated with the contact by doing the Sub Query like below Select firstname,lastname,(SELECT Id,Subject,Owner.Name FROM Tasks where Status = 'Completed' ORDER BY ...
2
votes
2answers
53 views

History field is blank for this query, Please help :)

I am new to salesforce, please help me out with this one: I am trying the following SOQL query to retrieve the changes made to the teacher object but I am getting nothing in the history tab. I turned ...
0
votes
1answer
35 views

Apex and SOQL Layered Updating

So I'm a little confused on how to do this. I'm trying to make a scheduled apex job to do some cleanup. A) On Account I am looking for Accounts with Type != "Type1" and Type != "Type2&...
0
votes
0answers
20 views

Delete sharing in a Trigger [duplicate]

I have a trigger which create sharing when a record is created and delete sharings when records are deleted. My problem is that I would like the request for the sharing to be basic and work when ...
1
vote
0answers
22 views

Salesforce query for working in code for testing

Below is the query i want to run without using tooling api is there a way possible if not how to use tooling api in my code as i Have never used it in code apart from dev console. SELECT ...
0
votes
1answer
46 views

SOQL for Loops giving an error: Too many query rows

I have the code below: Integer counter = 0; for(Account[] records: [SELECT Id FROM Account]) { counter += records.size(); } While executing this anonymous code, I am getting an error: Error on ...
1
vote
1answer
10 views

How do we query a Non-Guest User. (Test Methods failing)

How do we query for non Guest users. with the new Guest Ownership Rules Test methods are failing: First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception (Guest ...
1
vote
1answer
30 views

SOQL to Search by Record Id without sObject

I have a Flow that passes ID from the record on which user launched the Flow from, it could be Account, OPP, or Contact I don't know, I only get a RecordId. I want to be able to run a SOQL query in ...
7
votes
1answer
109 views

How to emulate SOQL LIKE matching in Apex?

I have a need to replicate SOQL's LIKE behaviour in Apex: The % wildcard matches zero or more characters The _ wildcard matches exactly one character Case insensitive including for cases where ...
0
votes
1answer
17 views

Copy value from a picklist in Product to Opportunity via OpportunityLineItems on update or insert

I'd like to share a solution for a problem that I've worked on and found some similar scenarios online but not quite exactly the same. So what are we trying to accomplish here? Every time an ...
0
votes
0answers
33 views

How to query 4 level parent-child in SOQL [duplicate]

I am working with a 4 Level parent - child Relationship: I have following custom objects Level1__c (Parent) Level2__c (Child) Level3__c (Grand Child) Level4__c (Great Grand child) I am trying to pull ...
0
votes
1answer
31 views

Dynamic SOQL Query -> Select Sum(Custom Metadata Field) Question

This is my first intro with custom metadata and also dynamic soql. I am trying to set it up so that users can set up certain fields that they would like to use for the apex class calculation via ...
0
votes
2answers
28 views

Reference Set<Id> in the WHERE clause of a Dynamic SOQL in Batch class

I have a Batch class and I am trying to reference a Set in the WHERE clause of a dynamic SOQL query but I have an error: System.QueryException: expecting a colon, found '{kA09E0000005mCySAI}' when ...
0
votes
2answers
34 views

Compare OldValue and NewValue in a Batch Class

I am trying to create a batch that send an Email anytime that status (Known_Error_Status__c) on a article is changed and the Article is 'Online' I have enable field history tracking on the object (...
0
votes
1answer
18 views

Query users having “Manage Content Permissions” OR “Manage Salesforce CRM Content” permission

I am trying to find out the API name and respective object where these permission are stored? "Manage Content Permissions" OR "Manage Salesforce CRM Content" I was able to find the ...
1
vote
1answer
10 views

Select foreign key for sub query when there are more than one candidates

In our Asset object, we have the standard Contact field (who, in our case, is the person who purchased the Asset). We also have a second Lookup(Contact) called Member__c who is the beneficary of the ...
1
vote
2answers
45 views

SOQL query for the “Where is this used?” button for a particular field

I am looking for a SOQL query that can display where a particular field is being referenced in Salesforce. Salesforce already has a button called "Where is this used?" for custom fields that ...
0
votes
1answer
20 views

Syntax for adding child records to List in APEX

Trying to work with a Master-Detail relationship in apex. The following code will produce a Case with several child records, and I can use list methods to access the records (i.e. the system.debug ...
1
vote
1answer
39 views

Joins or intersects in SOQL

I don't have relation between user and contact object, but they are related by data. id field in both of them is joinable. Select Id, email, Firstname, lastname from contact c where c.Id IN (select u....
0
votes
1answer
26 views

To update the list (error is maximum trigger depth exceeded)

I want to update the opportunity product servicedate , while updating the list it shows error the error is Production_date: execution of AfterUpdate caused by: System.DmlException: Update failed. ...
1
vote
2answers
50 views

Testing NavigationMenuItems without @TestVisible

I have a method to get the NavigationMenuItems for a provided Community is is possible to test this without using @TestVisible? So far I have tried to insert a community and NavigationMenu and ...
1
vote
1answer
26 views

SOQL not returning all results after adding new accounts

As an example, this very basic query SELECT name FROM Account in the developer console returns the many rows I would expect, however I have added two account records and they do not come up. However, ...
0
votes
2answers
39 views

Using WITH SECUIRTY_ENFORCED in WITHOUT SHARING class

I have a without sharing sharing class to insert Users and assign permission sets. Am using WITH SECURITY ENFORCED in select query Am facing an error: Insufficient permissions: secure query included ...
0
votes
2answers
21 views

API Question on relationships standard and custom

I have a query (below) but I want to connect to account and query name of the account. I have tried doing account.Name, account__r.Name but I get errors. select Customer_ID__c, Product2Id, ...
1
vote
2answers
55 views

Execute SOQL query via REST API in apex

I'm trying to execute an SOQL query via REST API call because I want to retrieve custom labels (ExternalString) previous to a date and by Category. I generate my query like this Datetime limitDate = ...
0
votes
1answer
31 views

Why isn't the list data being converted?

I have a method that gets a list of data from a database, transforms some fields and outputs them to a table. //helper getDataFromDB : function(component, helper){ let action = component.get('...
-2
votes
1answer
32 views

How can I correctly build a query to get the fields of an object I need from the database?

I am saving a new object to the database and I want to get information back in the form of the values ​​of specific fields of this object. How can I build a request correctly? This code only returns ...
0
votes
0answers
15 views

Retrieving parent records based on child conditions

I have contact as a parent object and program (custom object ) as child object , the relationship is lookup. I have a requirement to generate report for the contacts that have specific programs , for ...
0
votes
1answer
31 views

Hi. I'm trying to run this query in developer console and I keep getting Unexpected token “SELECT”

SELECT DMAPP__DM_Opportunity_Extra__r.DMAPP__Opportunity__c, DMAPP__DM_Opportunity_Extra__r.DMAPP__Opportunity__r.Name, COUNT(DMAPP__Contact__c) FROM ...
1
vote
1answer
23 views

SOQL: Count of Contacts associated with Accounts that have Opportunities

I need a count of Contacts that are associated with Accounts that have ever had an Opportunity. Here's the query as I think it should be SELECT count() FROM Contact WHERE AccountID in (SELECT id ...
0
votes
1answer
29 views

Running a SOQL from Apex Class Apex.Class.ClassName.FunctionName: line 111 Is causing high CPU Utlilzation

I have a function in which I query on Lead object and we have around 1 million leads. When we query on leads, we add a clause using a formula field in the query. for example, [SELECT Id, Name, Status ...
0
votes
1answer
22 views

Alternative for `Union` in Salesforce

I have the following columns uName1, uName2 ...... uName30 Since the name's length is long, if will be very difficult for me to read the screen using developer console and SOQL like this select ...
1
vote
2answers
39 views

SOQL RecordTypeName vs RecordTypeId

Id recordTypeId = Schema.SObjectType.Lead.getRecordTypeInfosByDeveloperName().get('ZS_Lead').getRecordTypeId(); List<Lead> leads = [Select Id, Name, LeadSource, OwnerId ...
0
votes
1answer
24 views

RecordTypeId in Where Clause

Id recordTypeId = Schema.SObjectType.Lead.getRecordTypeInfosByDeveloperName().get('ZS_Lead').getRecordTypeId(); System.debug('The FS Lead record Type Id is ' +recordTypeId ); // 011kjhjkhjkhkh List&...
0
votes
1answer
14 views

Replaying soql with today/yesterday literals

I have a cron job that DLs records using a jsforce query. It runs at 9:30UTC and attempts to DL all records in that day and then ALL of yesterday (so it basically should be a total of all records ...
0
votes
0answers
15 views

Declarative lookup rollup summary not working

I want to count total number tasks where subject = 'Call' related to a contact. I am using declarative lookup rollup summary package for to create the rollup field. When I try to save the record, it ...
0
votes
0answers
36 views

Transforming a read-only map<String,Object> criteria of a RemoteObjectController.retrieve into workable Apex SOQL?

How can a visualforce page (or the page's controller) access the NON-paginated results size of a Remote Object Model's RemoteController.retrieve query? Here is the relevant part of my override method,...
0
votes
1answer
28 views

Select other object's value in subquery

I have table UserPer which contains columns like uid1, uid2 ... What I want to do is like this Select uid1, (select name from user where id = up.uid1) from UserPer up How do I achieve this using SOQL?...
0
votes
1answer
21 views

SOQL to Pull LastLoginDate from past 2 hours but not last 30 minutes

Here is the scenario that I'm running in to. I need to able to pull users that logged in past 2 hours but not last 30 Minutes. I tried every possible way to filter this in but since we can't Use ...
0
votes
1answer
27 views

Running in to error First error: line 1:74 no viable alternative at character '"'

I'm trying to run a batch that makes user Inactive if logged in past 2 hours. It runs in to error ": line 1:74 no viable alternative at character" when i try to run this batch. I doubt if ...
0
votes
1answer
28 views

How to find FeedItem where a ContentDocument is the RelatedRecordId

Given a ContentDocument, I need a way to use SOQL to find any FeedItems that the ContentDocument may be related to. I hoped that ContentDocumentLink would work, but that just seems to give me the case ...
1
vote
1answer
33 views

Can we use custom settings in SOQL queries?

I need to use run a query based on the value in custom settings. Delete_Lookup__c is my custom settings. I need to change the output of query based on the values in custom settings. global class ...

1
2 3 4 5
102