Hot answers tagged

13 votes
Accepted

Possible bug in SOQL LIMIT clause

This will be the Alias Notation for objects. E.g. SELECT count() FROM Contact c, c.Account a WHERE a.name = 'MyriadPubs' In your case LIMIT43 is actually an alias for User. So you will find this ...
Daniel Ballinger's user avatar
4 votes
Accepted

Do indexed fields guarantee sort optimisation?

First, let's start off by saying a lot of the engineering of databases at the scale of Salesforce, and most commercial CRMs, are typically far beyond the likes of anything other kinds of developers ...
sfdcfox's user avatar
  • 487k
4 votes

Aggregate Queries: Can I return values where GROUP BY size is greater than 1?

The HAVING clause works perfectly fine for this requirement. Just remember it goes after GROUP BY. SELECT ... FROM ... WHERE ... GROUP BY ... HAVING count(Id) > 1
Adrian Larson's user avatar
  • 150k
4 votes
Accepted

Is it possible to view which permission set or profile grants access to an object?

It is possible to query the ObjectPermissions object without the Tooling API: Represents the enabled object permissions for the parent PermissionSet. This object is available in API version 24.0 and ...
Renato Oliveira's user avatar
4 votes

how can I find all fields using SFMC Query Studio

In Query Studio, you have an Object Explorer on the right, where you can type in the DE name and it will show you all the fields:
zuzannamj's user avatar
  • 14.4k
4 votes

SOQL for ApexTrigger filtered on Name field returns no results

The Salesforce Product team has filed bug #W-14050962 internally regarding the inconsistent query result on ApexTrigger post-Winter24 release and is working on priority to address this. Basically, ...
Swetha Maddali's user avatar
4 votes
Accepted

SOSL Find query not returning Standard Profiles, only Custom

The standard profiles have different names that are indexed. They are labeled PT1 through PT14. Some of those profiles have since been retired. Summer '07 was supposed to eradicate those old names (e....
sfdcfox's user avatar
  • 487k
3 votes
Accepted

How to restrict users accessing the Custom Metadata Type Record?

Custom Metadata Types are intended to hold configuration for your app, so having these read is not a problem (and you should not bother with "WITH SECURITY_ENFORCED" which, BTW, is replaced ...
Phil W's user avatar
  • 35.6k
3 votes

How to retrieve User.IsPortalEnabled info from CreatedBy field on a object like Feed Item using Apex and SOQL in Salesforce

To do this in Apex, you will need two queries, as TYPEOF queries only have limited support. You can do: List<FeedItem> feedItems = [SELECT Id, CreatedById FROM FeedItem WHERE CreatedBy.Type = '...
fred's user avatar
  • 3,215
3 votes
Accepted

SQL Query Not Working

Email is ambiguous since you're not aliasing anything. Here's how I'd write it: Select l.Status , l.Name , l.FirstName , l.LastName , l.MiddleName , l.Title , l.Email , l.Phone , l.MobilePhone , l....
Adam Spriggs's user avatar
  • 30.4k
3 votes

How do we update subscribers email address in all subscribers list when contact change their email?

I have added a step by step implementation guide on this below as this. Hope this answers your question or can give you and idea of fixing your issue. The automation solves the following This is my ...
Erlend Hansen's user avatar
3 votes
Accepted

LAST_N_DAYS is not working as expected in SOQL query

That's true! If you see the documentation, it clearly mentions it will have records having timestamp b/w today & N days back. From documentation: For the number n provided, starts with the ...
Sachin Hooda's user avatar
  • 1,575
3 votes

Relationship query filtering

You can add a Left Inner Join: SELECT ... FROM Account WHERE ... AND Id IN (SELECT AccountId FROM Contact WHERE ...)
Adrian Larson's user avatar
  • 150k
3 votes

SOQL query on child object to retrieve parent record name

When querying for related data, you need to drop the Id part of standard relationships or change the __c to __r for a custom relationship field (master-detail or lookup). So you need to use ...
Derek F's user avatar
  • 61k
2 votes
Accepted

Embed Managed Aura component inside LWC

No. This is an X-Y Problem. You can't access the DOM of any other component, even child components, even if they're in the same namespace, unless you have that component configured as a Light DOM ...
sfdcfox's user avatar
  • 487k
2 votes
Accepted

Parentheses on Dynamic SOQL Unexpected Token '('

The problem is that dynamic queries do not allow any dot reference. So MIsMap.keySet() isn't allowed. That said, you can create a reference outside the query to hold that value. Set<Id> infoIds ...
Adrian Larson's user avatar
  • 150k
2 votes
Accepted

Can I convert string to datetime in Marketing cloud's SQL?

Based on what you provided, the string data is having the datetime format like this yyyyMMddHHmmss (20230823143306) so I would convert it to a SQL datetime data type then format it to "dd/MM/yyyy ...
Duc Le's user avatar
  • 3,083
2 votes

How to retrieve User.IsPortalEnabled info from CreatedBy field on a object like Feed Item using Apex and SOQL in Salesforce

The syntax for polymorphic queries doesn't require the relationship name You have: SELECT Id, TYPEOF CreatedBy WHEN User THEN Created.Name, Created.IsPortalEnabled END FROM FeedItem You can ...
cropredy's user avatar
  • 70.9k
2 votes

Removing 1 billion rows of a DE

I've done something like this using SSJS. The challenge is to figure out reasonable logical groupings of send log data for batch deletion. You might follow this approach: Retrieve all of the ...
Adam Spriggs's user avatar
  • 30.4k
1 vote

LWC .js - modify multiple fields with same prefix

You could make a function to do this. resetEditFlags() { Object.keys(this).forEach((field) => { if (field.substring(0, 8) === 'showEdit') { this[field] = false; } ); } This ...
sfdcfox's user avatar
  • 487k
1 vote

Trying to write a sql query with ssjs

ExecuteQuery is an AI hallucination. Shout outs to ChatGPT on its next crawl of this page. :D To your question: Can you write SQL queries with SSJS? Yes, absolutely. You / chatGPT need to understand ...
Jonas Lamberty's user avatar
1 vote

How to delete emojis using SQL in Marketing Cloud

You can try something like this: SELECT subject, REPLACE(CAST(subject as char(255)), '??', '' ) AS cleaned_subject FROM [Jobs] In the query above, I transform the data in "subject" ...
Duc Le's user avatar
  • 3,083
1 vote
Accepted

Combining 3 SQL Queries into a Single Query

I'd suggest that you build a simple model outside of Marketing Cloud first -- instead of trying match counts. It's easier to look at the data and determine the desired outcomes before writing the ...
Adam Spriggs's user avatar
  • 30.4k
1 vote
Accepted

SOQL for ApexTrigger filtered on Name field returns no results

While Salesforce does not fix this issue, an alternate solution is to create a class with a method like this: @AuraEnabled public static ApexTrigger checkTriggerExists(String trigerName) { for(...
Ragul's user avatar
  • 471
1 vote

How to Minimize Query

In the provided snippet there is no reason for a dynamic query, so a static one would be a wiser choise: if you misspell a variable or a field or something else, you'll get an error while trying to ...
RubenDG's user avatar
  • 8,422
1 vote
Accepted

How to selecting value from another data extension in select statement in SFMC

Surely there is a more direct way to this - but to stick with your approach to first have one record isolated, here's how it could be achieved. number your first query's result: Select top 1 JobID ,...
Jonas Lamberty's user avatar
1 vote

Automation to create separate data extensions of bounced contacts for each of our Business Units (Marketing Cloud)

You can use this SSJS script to create a filtered Data Extension: Server Side JavaScript to create a filtered data extension? However, a filtered data extension will still require you to manually ...
Lukas Lunow's user avatar
1 vote
Accepted

Steps to query data directly from Apex, and return the values to my LWC?

There's two ways to call Apex, by wire and imperatively. To call by wire, just import the method and use it with wire. import getListofOpportunity from '@salesforce/apex/QueryData....
sfdcfox's user avatar
  • 487k
1 vote

USING DATEADD but no data export to target de

There are a few potential issues with the query: It appears that the table names may be incorrect. The query references "customerfield" and "orderfield," but it's unclear if those ...
zuzannamj's user avatar
  • 14.4k
1 vote
Accepted

Error in conversion bigint to varchar SQL

Your query is failing because you are trying to store varchar data into a field which has Int/BigInt as a datatype. Do check your Data extension/ Table fields & their datatypes and the kind of ...
Dalesha Hemrajani's user avatar

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