Questions tagged [query]

A query is an inquiry into the database using the SELECT statement. A query is used to extract data from the database in a readable format according to the user's request.

Filter by
Sorted by
Tagged with
40
votes
3answers
17k views

Workaround for Offset 2000 limit on SOQL Query

Problem I'm trying to make a standard query pagination. I'm using SOAP API. The logic is classic: LIMIT recordsByPage OFFSET (recordsByPage*pageNumber)+1, It works fine, however, I'm facing the ...
8
votes
1answer
7k views

Query Which Profiles Have Read Access To Specific Object?

Since I couldn't think of how to write this query off the top of my head, I thought it might be worth sharing. How can I query which Profiles have Read permission on a specific object? I knew it would ...
2
votes
2answers
3k views

Query Activity Failing

I have set up a data extension to capture a query and return it's results. In order to track the query, I am running it in automation studio. However, the query keeps failing. I have checked that the ...
12
votes
1answer
511 views

Variable scope - database.query() has access to variables not in scope

I was answering a question and this little inconsistency popped up. Just wondering if anyone has come across it before, or if anyone knows why this happens. A variable that is declared within some ...
6
votes
1answer
2k views

Trying to get SymbolTable of an Apex class and get null

I'm quering Apex classes using Tooling API QueryResult queryResult = toolingConnection.query("select Id, ApiVersion, Name, NamespacePrefix, SymbolTable, Body from ApexClass where NamespacePrefix = ...
2
votes
1answer
1k views

External Id in salesforce

I have an external system that needs to update a record in my org. This system only knows the external id, but the problem is that this external id is not unique, e.g. multiple records might have the ...
0
votes
1answer
52 views

List has no row exception: Queryerror

I have below line placed in controller that fires list has no row exception. I just need to show a custom message instead when the query returns no value. Apex code: Id CI=[select ...
12
votes
3answers
34k views

How to query all user with salesforce license?

I want query the list of user with salesforce license List<user> user11=[SELECT name from user limit 5000];
5
votes
2answers
2k views

How do we refer Bulk Data Load Jobs in Apex

I have a requirement where, we need to send an Email on the status of failed Bulk Data Load jobs. But I am not sure the Object Name or how to refer those jobs programatically in my APex code. When I ...
2
votes
1answer
2k views

What is wrong with this query? (Unknown error parsing query)

When I run the following query in query editor I get this error. Error Unknown error parsing query Query SELECT Id, OwnerId,Account.OwnerId FROM Contact where OwnerId = Account.OwnerId limit 100 ...
0
votes
1answer
4k views

Soql query for retrieving images from notes and attachments

I want retrieve image from documents in not other notes like pdf,ext... please how to write soql query
14
votes
2answers
24k views

How is a DateTime object formatted into a String suitable for a String based SOQL query?

In order to write a where clause against a datetime field, you need to format your dateTime object into the following format: WHERE SystemModstamp > 2005-10-08T01:02:03Z How do you correctly ...
15
votes
1answer
865 views

How can adding a Subselect make a SOQL query non-selective?

I have a SOQL Query with subquery that fails to execute because it is non-selective. I don't understand why and cannot interpret the results. All I know is that tearing parent und sub query apart ...
-1
votes
1answer
6k views

How to Query a Data Extension and Update the Subscriber list at the Child Business Unit Level?

How to Query a Data Extension and Update the Subscriber list at the Child Business Unit Level without using landing pages?
6
votes
2answers
6k views

Query Chatter Feed, Topics, and Groups

First off, my end goal is lofty and time-consuming, but we need metrics and this is the best way to do it (that I can think of). Originally, a chatter post was created on the quote, case, or where ...
5
votes
1answer
5k views

Inline query has too many rows for direct assignment, use FOR loop

I am receiving an error stated above on line 26**(listAccount1)**, can anyone guide me on how to solve it? public class FRB_UpdateExceptionsforBatch { public static void FRB_Exceptions(){ ...
2
votes
3answers
10k views

Nested SOQL query?

so, the following query is pretty self explanatory: SELECT p.Accountid, p.Name, (select name FROM Account where id = p.Accountid) FROM Contact p order by accountid' is there any way to do this in a ...
15
votes
3answers
28k views

Filtering by Long Text Area field in SOQL

I'm working on a custom search page, which will search through the fields of the Project object. I use dynamic SOQL query similar to that: String query = 'SELECT Name, Status__c ... FROM ...
7
votes
2answers
9k views

Retrive globalpicklist/globalvalueset without SOQL

Is it possible to retrieve the values of a Global Picklist/GlobalValueSet using Schema class without a SOQL ?
0
votes
0answers
122 views

querying Recently account viewed

How how do I query recent account views and group by LastViewedDate SELECT Id, Name FROM Account ORDER BY Name DESC limit 10 FOR VIEW I used to have it like this, ...
7
votes
4answers
6k views

How do I SOSL across objects, matching all records with FIND clause?

To all the expert SOSL gurus lurking out there, I thought this will be an interesting one: I have some SObjects of different types and I want to return their Name values in a single query. In ...
7
votes
2answers
1k views

DateTime.Format() Documentation example causes exception

I'm trying to get a DateTime to format into a value to be used in a dynamic query. For some reason, the documentation snippet on how to format a DateTime for a query is giving me an exception. Im ...
6
votes
1answer
1k views

SOSL query returns only 250 records even if there are more than 2000+ records present

I have two queries List<sobject> soslRecords1 = Search.query('FIND {I need help res*} in all fields returning Incident__c (id) where ID IN:rec_ids')[0]; List<sobject> ...
6
votes
1answer
1k views

Soql query on parents other child object

I want to write a soql query , My scenario is as follows. I have three objects objectA,objectB,objectC. objectA is the parent object for both objectB,objectC. objectA - objectB (Master-detail ...
5
votes
2answers
2k views

Retrieve Force.com registered domain

I need to return this value: Is there anyway to get the registered Force.com domain for a given org, with raw Apex code or Metadata API?
2
votes
1answer
695 views

Didn't Understand Relationship - How To Find Child Relationship Name?

I have a many-to many relationship between three objects. LGFProducts, PartsinProducts, and Parts. PartsinProducts is the junction object. I want to be able to get data like the names of the parts ...
2
votes
2answers
129 views

Query to Include Child Junction Records - Didn't Understand Relationship

I have a Junction object name AcctContactAff which creates a many-to-many relationship between Contacts and Accounts and stores (among other things) the title of the person at the account. ...
1
vote
1answer
75 views

How to get list of all sobject records modified today in the system?

I need a list of all sobject records that got modified today. this is not just for one object but for all objects in the system. Is there a simpler way to do this?
1
vote
2answers
6k views

SOQL query is not working in Test class coverage

I wrote three soql queries in test class static testMethod void test_DoGet() { RestRequest req = new RestRequest(); RestResponse res = new RestResponse(); ...
0
votes
2answers
41 views

SOQL query for Multiselect picklist

Hello I'm trying to use string in SOQL query where clause for multiselect picklist. I need to get records of CustObj__c where Multipicklist__c fild have 'abc' or 'xyz' values. String str = '\'abc\',\...
-1
votes
1answer
231 views

Too Many Records in salesforce

I have More amount of Records in salesforce, i have created field as not Unique.So for account Records is created with duplicate Records also,I want to check how many Records contain dulplicate ...
-2
votes
1answer
432 views

Parent to child SOQL query is not working

SELECT Id, CurrencyIsoCode, ExpirationDate__c, (SELECT Id, Regional_Starting_Price_2__c FROM SBQQ__QuoteLine__c) FROM SBQQ__Quote__c WHERE ...
11
votes
5answers
11k views

Can a SOQL query selecting all columns be generated at runtime?

It seems like SOQL does not have an equivalent to SQL's "SELECT * FROM ..." (If SOQL has this syntax, show me and I will mark that as the answer.) To get around this limitation, I have been using a ...
8
votes
1answer
1k views

ORs and ANDs in the retrieve function of Visualforce Remote Objects

Related: OR/AND condition for complex criteria with remote objects Background The retrieve query format allows the use of or and and clauses to create complex queries. The relevant documentation is ...
5
votes
1answer
7k views

How to query the data that has been modified in last 30 MINUTES

we have Order__c as custom object. we are trying to extract the past 30 minutes record. where LastModifiedDate=TODAY and HOUR_IN_DAY(LastModifiedDate) > 0.5 is not working We tried SOQL : ...
4
votes
1answer
1k views

How to iterate repetitive rows in table to calculate count and show the sum

I am new to vf tables and repeat tags. i am trying to create the below table in vf page could anyone please help me to achieve this by telling the way how i can do the below:- Object- Family Fields-...
1
vote
1answer
658 views

How do you query for users that did not open an email by JobID in marketing cloud?

I'm trying to figure out how to extract users that did not open an email with specific jobID's. This is what I have so far that doesn't seem to be working correctly. Any help would be appreciated. ...
10
votes
1answer
8k views

Make SOQL Case-Insensitive?

I have this query: List<id> accounts1 = [SELECT Id, PersonContactId, PersonEmail, FirstName, LastName, net_Id__pc FROM Account where net_Id__pc = pFederationID] I need ...
7
votes
1answer
10k views

Query all queues I am a member of

I would like to query all hardcodequeue groups I am a member of. So far it seems I can only query a queue if I hard-code it's name. There doesn't seem to be a way to query a queue and have it return ...
7
votes
2answers
81 views

How to query an Installed Package Id

I'm trying to properly build a relative URL from within a managed package context, so that a simple link can be provided to the user to bring them to the assign licenses page specifically for that ...
4
votes
2answers
2k views

Why does Database.query perform so bad as opposed to [… my_soql_here …]?

I looked at this, but clearly there appears to be a big difference between the two. Can someone please explain the behavior and/or suggest a workaround? I already posted this comment in this ...
4
votes
2answers
5k views

Query Activity system error in Automation Studio

Why am I getting a system error with this Query Activity in Automation Studio? Select o.AccountID , o.JobID , o.SubscriberKey , o.EventDate , o.isUnique , o‌​.Domain , o.Subscriber‌​ID , o....
2
votes
4answers
6k views

Help with writing basic statistics query

Struggling for a while with trying to extract basic statistics of our company emails status. What we want to get is a query that will extract the following stats.: Probably taken from Send Log table:...
0
votes
1answer
3k views

Queries on 'All subscribers' attributes in Marketing Cloud

I have an attribute called CardId in my all subscribers list and want to query it, but I get the following error if I do so: "The query syntax is invalid" Invalid column name 'CardId'. This is the ...
0
votes
1answer
882 views

Unique coupon codes to same subscriber [closed]

Here is the requirement - A customer purchases 2 assets, we should be sending two different coupon codes to the same subscriber. Based on the requirement, we have changed the code (Query) to assign ...
0
votes
3answers
180 views

How to de-dupe a field “Email_Adress” using AMPscript

I'm performing a data pull from a source DE, some of the records are being imported more than once. My Query currently looks for: SELECT * FROM XXX_DE_NAME WHERE ID = 'XXXXXX' The field name is ...
8
votes
5answers
997 views

Why isn't a SOQL query of mine populating a list in an Apex test class?

Why does my taskOpp query below not return any records when I run this test? The query works fine in Workbench and my taskRT query works fine in both my code and in Workbench. public class ...
6
votes
1answer
6k views

SOQL to find All Users with a Custom Permission

I was looking for a little help to find all users with a particular Custom Permission assigned to them, either via Profile or Permission Set.
6
votes
1answer
871 views

RestAPI nextRecordsURL lifetime

we are currently working on POC that queries large amounts records through RestAPI. For queries that exceed the batch query size, a nextRecordsURL gets returned. Does anyone know what the lifetime of ...
5
votes
0answers
951 views

Apex equivalent of REST api's nextRecordsUrl

When you run a query through the REST api and the number of records returned exceeds the default 2000, or the batch size set in the Sforce-Query-Options header, the query will return a nextRecordsUrl ...