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
1 vote
1 answer
26 views

Queries on Large Object (>1 million rows) Fail to Execute

We have an object with approximately 1.5 million records in Salesforce. These records are created in an external system and synced with Salesforce every 24 hours. On a 24 hour basis, we delete all 1.5 ...
user avatar
  • 162
0 votes
1 answer
44 views

how to use SSJS to extract all distinct values (may require looping) and push it to sql query in marketing cloud?

I am new to SSJS and have not used it yet. I have a use case where I need to extract JobID and EmailName from SendLog Data Extension. I use JobID and EmailName in SQL query but right now I need to run ...
user avatar
  • 99
0 votes
1 answer
20 views

Query Failed Timeout in Automation

I have this query inside an automation where it is executed with many other queries that are working fine, but when I run this one, the following error appears: query failed: timeout. How could I ...
user avatar
  • 5
-1 votes
1 answer
24 views

How to compare values in soql query when field may have a different format

I don't know if there is a way to solve this, I couldn't find it. I am importing a CSV file where I am to create an sObject for each line. The thing is, I have to do a query using a value present in ...
user avatar
2 votes
1 answer
114 views

Lean, fast and flexible replacement for the fflib QueryFactory

I just decided to kick the fflib QueryFactory out of a customer project because of its complexity and sub-par performance. My Custom Query Building is fast but I fear I will reinvent the wheel. Which ...
user avatar
-1 votes
0 answers
28 views

select all record from a related list without having to select them

I am using a standardSetController in constructor of my extention, wich let me use the functions getRecords() and GetSelected() The problem is that getRecords() gives me a list of ALL the records of ...
user avatar
  • 23
-2 votes
0 answers
26 views

How to remove a word appear the second time on a string

ex: String = stringQuery = SELECT opp_name__c, account_name__c, system_on_change_date__c, old_pic__c, Opportunity_id__c, PIC_change_date__c, Pic_new__c From PicChangeHistory__c WHERE Pic_new__c ...
user avatar
-1 votes
1 answer
41 views

Can someone explain me the difference between these two queries [Select a.Name From account a] and [Select Name From account ]

Why do we need to create instance of an object in an query and what difference does it make from normal query. I tried running these query and couldn't notice a difference I was going through some old ...
user avatar
0 votes
0 answers
36 views

Avoid query inside for in Trigger

Hi I am new at Salesforce I did a LWC form that creates a record. Some fields of this record can´t be filled by the user so I did a Trigger for the custom object that creates this record. The problem ...
user avatar
0 votes
1 answer
13 views

Need help with a SQL query to marry Click and Subscriber data

I'm trying to run a query that will return all of the clicks from a specific email send including alias and email. I need to then marry that data with a custom attribute in our subscriber data (...
user avatar
1 vote
1 answer
40 views

How to fetch name field for a record of given record id but known object?

I am trying to obtain all related child (look up) records of a record whose record id is passed. Salesforce docs say that for every object, regardless of type, name is a standard field, just like Id. ...
user avatar
0 votes
1 answer
27 views

Database.query() question

Is it ok to use String.escapeSingleQuotes() inside of a database.query() or do you need to create a new variable using the String.escapeSingleQuotes() first and then use the new variable in the ...
user avatar
-1 votes
1 answer
44 views

SOQL queries Where Clause given Error UNEXPECTED Token

[ SELECT Name, (SELECT Communication_Type__c, Communication_Mode__c, Additional_Information__c, CBProgramInformation__r, Reporting_Type__c FROM Reporting_Detail__c ) FROM ...
user avatar
-1 votes
1 answer
172 views

To avoid SOQl query inside for loop

I have the below code and there is a SOQL query inside for loop. I have been instructed to avoid SOQL in the loop as these are invoked for every iteration of the loop. Since i am a beginner in ...
user avatar
-2 votes
1 answer
43 views

Method does not exist or incorrect signature: void getOppty(Id) from the type classname (108:19)

I want to do a refactor from this map, so I try with a method, this is how I try: private static Map<Id,Opportunity> getOppty (Set<Id> solutionId) { Map<Id, Opportunity> oppties = ...
user avatar
  • 3
0 votes
1 answer
34 views

How to obtain child records for a given parent record and vice versa?

I want to create an Apex function that takes a recordId of unknown entity type, identifies the entity type and subsequently returns all child records (name, id) of the given record. In addition, the ...
user avatar
0 votes
1 answer
30 views

Tracking number of contact attempts based on Tasks under Contact

I need to update a custom field called Contact Attempts on the Contact sobject with a numerical value equal to the number of all Tasks associated with the Contact. Any time a Task is added or deleted, ...
user avatar
  • 5
-3 votes
1 answer
41 views

An error occurred while checking the query syntax. Errors: Incorrect syntax near ')' [closed]

Hello i want to count with condition but i got syntax error , i don't where the issue is this is my query : SELECT Statut__pc as 'Statut', Count(CASE OptinInvitationsVente__pc when 'true' THEN 1 ELSE ...
user avatar
0 votes
0 answers
32 views

How can I add a query activity on a running automation to start a new journey?

I am new at Marketing Cloud, so I am sorry if this is a silly question but I could use some help. I have an automation running with a query activity to combine different objects and populate a Data ...
user avatar
0 votes
1 answer
18 views

removing duplicates from a database.query based off a single field within that record

Here's the query: Merchandise__c[] merchList = Database.query('SELECT ' + lookupFieldApiName +'.Id, '+ lookupFieldApiName +'.Name ' + '...
user avatar
  • 464
0 votes
1 answer
63 views

Sql query to exclude related records in dataset

I am attempting to create an sql query in salesforce marketing cloud...I have a list of email addresses, the number of products they own, and the associated product codes. I would like to set up the ...
user avatar
0 votes
1 answer
165 views

How to Query Child records of the lookup record in a single query

I have 3 custom objects Organization__c School__c Student__c The objects are related like below: Object Organization__c has a lookup field School__c which is a lookup on the object School__c. ...
user avatar
  • 133
-1 votes
1 answer
23 views

Order Query Results aside from ASC and DESC

I have a query that returns the following results: Apple Banana Grape Pomelo Is there a way to make the "Grape" appear on top of the results? Adding a new field to be used as an ordering ...
user avatar
  • 103
0 votes
2 answers
29 views

how to write a query to filter the multiple input field of account

public with sharing class SearchComponent{ @AuraEnabled(cacheable=true) public static List<Account> getAccountList(String searchKey) { String key = '%' + searchKey + '%'; return [...
user avatar
1 vote
1 answer
46 views

Logic problem, it is possible? Add more quotelineitems if it has more than 1 on quantity

Hello Guys. My method does not work correctly. What it does is call another method inside a loop, the functionality is to take each quotelineitem from the quote until it finishes collecting all the ...
user avatar
0 votes
0 answers
18 views

Add quotelineitem depending of quantity

Hello Guys. My method does not work correctly. What it does is call another method inside a loop, the functionality is to take each quotelineitem from the quote until it finishes collecting all the ...
user avatar
0 votes
2 answers
252 views

How to query related Contact from Account by Id in "after insert, before update" trigger?

I need to query the related Contact after a new Account is inserted and before it is updated, but I am encountering an error: System.QueryException: List has no rows for assignment to SObject. I've ...
user avatar
  • 5
0 votes
1 answer
33 views

Create list with two queries

i have this query: Set<Id> drIds = new Set<Id>(); List<custom_Object__c> dr = [SELECT id, name FROM custom_Object__c WHERE AcountId__c =: accountId]; for(custom_Object__c drl :dr) { ...
user avatar
0 votes
0 answers
66 views

Error too many rows 50001 in a custom Rest API

I have a custom rest API that when is called from a third party system (this third party system calls me providing a country code like UK, DE, US... and some other parameters) I filter account object ...
user avatar
  • 1
0 votes
0 answers
69 views

how to find out total number of subscribers who were sent 1 email in last from in salesforce marketing cloud

I am trying to get a count of all subscribers (irrespective of BU) - hence I am running the query in parent BU who received ONLY 1 email in previous month. This is my query but it is not returning any ...
user avatar
  • 99
0 votes
1 answer
22 views

I am getting FATAL_ERROR System.QueryException: unexpected token: BM_DPM_Date__c

I am facing the following issue. I wrote this query for the start method of my batch class. global Date startDate; global Date endDate; global Date currentDate; global Database.QueryLocator start(...
user avatar
  • 35
0 votes
1 answer
71 views

Query to Combine Data from 3 different Data View Tables

I've pulled the last 30 days of data from 3 data view tables (Job, Open, and Click) into 3 different data extensions. I'm attempting to run a query to dump data from my 3 different data extensions ...
user avatar
0 votes
1 answer
57 views

_Open.IsUnique is TRUE for two records with the same JobId and SubscriberKey - Why?

From my understanding, the first "open" that's recorded for a particular JobId will have their IsUnique attribute as TRUE. Any subsequent opens AFTER that will still be recorded, but with ...
user avatar
1 vote
2 answers
120 views

Query Studio SQL statement to pull data date range function syntax

I'm using Query Studio in SFMC - Is there a better way to write this query? I checked the DE - I 99% sure there are records to see but doubting myself if I'm writing this correctly. I'm just trying ...
user avatar
  • 13
0 votes
1 answer
58 views

Escape underscore (_) in SOQL LIKE clause

Before you point me to LIKE Clause documentation, I already read it. I created new custom object thats API name is TestObject__c. Now I would like to query my custom objects. So I need to find the ...
user avatar
0 votes
1 answer
54 views

MobileConnect: Query that will show OptInStatus for all contacts

I need to see the OptInStatus for all contacts in MobileConnect. I've tried querying off of the SMSSubscriptionLog data view, but I'm not very strong with SQL. Here is the query I've been using, but ...
user avatar
0 votes
1 answer
60 views

Records duplicated on SQL Join (Marketing Cloud)

I'm trying to return the results of subscribers who have been sent emails, when they've been sent, if they've opened/clicked and whether or not is house bounced/they've unsubscribed. I'm using the ...
user avatar
-3 votes
1 answer
70 views

SOQL nested query not working

I want to save the following query but it given me errors: Query: Set<Id> extUserIdSet = new Set<Id>(); List<Object1> obj1= [ SELECT Id, ExternalId, Name, Address, ( ...
user avatar
0 votes
1 answer
36 views

Write SOQL nested query

I have two objects. Object2 has lookup relationship to Object1. I want to write a SOQL query to fetch some data of Object1 where the territory field of Object2 is equal to UK. Set<Id> ...
user avatar
1 vote
0 answers
22 views

How to reset the off set value after 2000 records

I have aura component which fetch the records And I have a Object that has 2100 records Now I have to navigate to the last record page but it is not possible because of offset limit so how to overcome ...
user avatar
0 votes
1 answer
46 views

Query not executing

select top(200) * FROM ._Click C with (nolock) INNER JOIN CLM_Sendlog S with (nolock) on S.TriggeredSendID = C.TriggererSendDefinitionObjectID where C.TriggererSendDefinitionObjectID = '7e248b8b-...
user avatar
  • 1
0 votes
1 answer
30 views

Same Bulk API Query success at local but failed after deploy to Airflow

I have tried all the ways to debug the code, also check the library version between my local machine and server, they are same. Following is the query success at local: sfdc query: SELECT Id,OwnerId,...
user avatar
0 votes
1 answer
125 views

Count the number of contacts in each Business Unit

I have 2 BUs in the Marketing Cloud and each has its own contacts. My issue is that I want to retrieve the number of contacts in each BUs (no need to be exact, just an appropriate number would be ...
user avatar
0 votes
0 answers
24 views

Split throught % of Open Rate

I have a journey where I send a 1st email and after that email I have to evaluate the opening % of that 1st email. In one way I will send another email to everyone who has an open rate > 20% and ...
user avatar
  • 1
-2 votes
1 answer
267 views

Get for each parent record all child records of a specific object type in a map<parentid, list<childobject>> [closed]

I'm trying to figure out the correct approach to get for each parent record in a list : all the specific sobject child records related to that specific parent record. And I would like to arrange them ...
user avatar
  • 1
0 votes
1 answer
121 views

SQL Query Timeout Help SFMC

I have the following query that is consistently timing out for the last few weeks. It had ran perfectly fine since 2019, previously. I know the query needs to be optimized, but I don't see anything ...
user avatar
0 votes
1 answer
199 views

SQL query to update field only if it is empty

I need to run a query which updates a target DE with some rows from another. There is a field called 'origin' which shows on the target data extension where the data came from. I appreciate this may ...
user avatar
  • 802
0 votes
0 answers
75 views

What should be used to search a string across multiple fields of a single object? SOQL or SOSL

I want to search records for a particular object based on filter string that can match multiple fields on that object. This can be achieved via both SOQL and SOSL: SOQL : using like operator, applying ...
user avatar
  • 2,450
0 votes
0 answers
32 views

conn.query() method is not returning all the records

I am trying to create a custom sfdx plugin, for that I am fetching a query result using const result = await connection.query(SOQLQuery); but it is not giving me all the records which are present in ...
user avatar
0 votes
1 answer
50 views

How to list all record ids if "SELECT Id FROM ObjectName" returns fails with QUERY_TIMEOUT?

I need literally all the records. Documentation says that if I hit 120 sec. limit then I should refactor my query to retrieve less amount of data. The only option not to skip data but collect it part ...
user avatar

1
2 3 4 5
32