Hot answers tagged

7

The answer is NO A far better practice is to store API names in custom settings/custom metadata and query for the resource by apiName in the code: API Names are more transparent than IDs Custom metadata values can be deployed Sandboxes created from PROD that include ID values might be broken if the IDs point at data records not present in the sandbox (such ...


7

This occurs because of an optimization during the "query planning" phase of a query. The query optimizer removes null values from filters on required fields. This optimization allows Salesforce to use standard indexes instead of a full table scan on those fields, which can improve performance by many orders of magnitude on large tables. If Salesforce fixed ...


6

Aura, and LWC, groups several requests together in order to maximize performance. This is called "boxcar'ing" (or boxcarring) in the documentation. All Apex requests in the same boxcar payload are subject to a single set of governor limits, even though they're allowed to fail/succeed independently. This means you need to make sure you don't place DML before ...


6

If your target Data Extension's primary key is just Subscriber Key, I'd expect a primary key violation since you're joining with a one-to-many relationship (MasterSubscribers -> _Click). I think you can achieve what you want without a JOIN: select m.SubscriberKey , m.EmailAddress , m.Country , m.Language , m.Gender , m.FirstName , m.LastName , m....


6

I would look into using Query Studio which is much more user-friendly and better for trial and error development work. Query Studio. It will help you as you learn and get up to speed. I'd also really recommend reviewing the query/SQL documentation that SFMC has provided because it will help understand the limitations of SQL in SFMC vs the outside world. ...


5

The closest you can get to this would be to use SOSL: ApexClass[] schedulableClasses = (ApexClass[]) [FIND "schedulable" IN ALL FIELDS RETURNING ApexClass(NamespacePrefix, Name)][0]; This is not foolproof, as it could return classes that merely have this in a comment or something, but you can then try to instantiate each one to see if it really ...


5

My answer is that it doesn't matter for this example as the volume of data you are dealing with - 340 records - is small so optimization is way down the priorities. My priority list is ballpark this if there is nothing extreme about the code: Code that works Tests that prove the code works Code that doesn't run into query or CPU or heap governor limits Code ...


5

One possible solution would be to write a query to copy everything from your data extension into a new data extension. You could then check the new data extension against the original to see if any values have changed. This could all be run inside of an automation to run at an interval of your choosing. The first query in the automation will check to see if ...


4

If you deployed the field but didn't deploy any profiles then the field security needs to be updated. By default when you deploy a field on its own nobody has access to view it or edit it. Check your field level security for your new field in production.


4

You can use SetupEntityAccess and Apex class to get required information. First SOQL will show all apex class Ids which is enabled for permission set 'CustomPermission'. Second SOQL will show Apex Class Name based on first query result. Map<ID,AggregateResult> mapAccess=new Map<Id, AggregateResult>([SELECT SetupEntityId Id FROM ...


4

Date data types in SFMC are DateTime (or DateTime2) data types behind the scenes, so the time is always included. It's best to use AMPscript to format these, as you can't dictate the format stored in the data extension unless you store them as Text. I generally just use the formatDate() function in AMPscript: %%[ var @date_field set @date_field = ...


4

What you are seeing here is a typical example of Journey Data vs Contact Data. However confusing it might be, accessing the journey DE through the contact model does not automatically make it updated. I could add any data extension to the contact model, this will not make it automatically updated. Here I also do admit that the fact of these data extensions ...


4

This seems like unexplainable bug. When there is exactly 1 word between 2 names like name someWord name someOtherWord, it does not return the record. However, if you add spaces for wildcard characters, it seems to be fine: FIND {Name * Name *} IN NAME FIELDS RETURNING ACCOUNT (Name)


4

I know you said there are no duplicate emails, but it might be best to set up a dedupe subquery to validate this: SELECT a.* FROM ( select s.Magento_ID as Magento_ID, case when r.[Marketing Cloud_ID] is null or r.[Marketing Cloud_ID] = '' then s.EmailAddress else r.[Marketing Cloud_ID] end as [Marketing Cloud_ID], s.EmailAddress as ...


4

You could probably do it using a LIKE statement concatting the wildcards before and after the column. e.g. click.LinkContent LIKE '%/' + prod.ProductID + '?%' So full sample (with dummy fields, etc.) SELECT prod.ProductID , yourOtherFields FROM [ProductIDs] prod INNER JOIN [_Click] click ON click.LinkContent LIKE '%/' + prod.ProductID + '\?%' WHERE click....


4

The issue might be that the date format of the two is not matching correctly. Try using: DATEDIFF(year, CAST(creation_date__c as DATE), CAST(getdate() as DATE)) So that you cast each as identical data types, which should remove any possible data mismatch.


4

Your first query does not include the _Open data view, so it won't work for your use case. If you want to display all subscribers who opened an email, you can use the following, bearing in mind what Lukas said - Data Views only hold last 6 months worth of tracking data: SELECT s.SubscriberKey, j.EmailName, s.EventDate as SentDate, o.EventDate as ...


4

Unfortunately you cannot target a filtered Data Extension with a query. These are able to be manipulated by your filter only. If you cannot utilize the filter to get what you need, you will need to create a new data extension to target with the query. If your filter is appropriate/sufficient and you just want to automate it, you can utilize a filter ...


4

You do not have to convert the string to lookup field, the lookup Id is a string: Id neededId = Id.valueOf(msg.to_WhatId__c); String objectAPIName = neededId.getSobjectType().getDescribe().name; if(objectAPIName == 'Gear__c'){ // assign the lookup value msg.Gear__c = neededId; } If for some business purpose, you need to refactor the code to avoid ...


4

The first answer is entirely correct, BUT the solution has become much easier lately, with the introduction of the new data view businessUnitUnsubscribes, which eliminates the need for the (correct) workaround linked by Brad. https://help.salesforce.com/apex/HTViewHelpDoc?id=mc_as_data_view_businessunitunsubscribes.htm&language=en_us Hope this helps! ...


4

You need to run this in the ENT BU to get records, as it sounds that you might have a subscriber filter configured. When you send an email to a data extension, the contacts will always be added to All Subscribers in ENT BU. These are shared across the enterprise, however you can manage subscribers so they only appear at a specific child business unit level. ...


3

Yes, you can use a join to find only records which have child records meeting certain criteria. SELECT ... FROM MyObject__c WHERE Id IN ( SELECT Lookup__c FROM Child__c WHERE ... ) So in your case, if your child object is named VotingRelatedCompany__c, it would look like: WHERE Id IN ( SELECT Company__c FROM VotingRelatedCompany__c WHERE ...


3

As your code is right now, moreInfo is an empty List, so you shouldn't be getting any results: List<String> moreInfo = new List<String>(); // <=== EMPTY right now! List<Detail__c> details = [SELECT Info__c FROM Detail__c WHERE MoreInfo__c IN : moreInfo LIMIT 1]; Use your for loop before the details ...


3

Its called as boxcarring, Salesforce bundles multiple request in to 1 to save repeated calls to server. You can seee from Debug logs, only one is created. A quick solution is to add a timeout or use the promise chain while calling apex. In this way , each apex call will be treated as new transaction and those limits get reset. new Promise(function(resolve,...


3

If you cannot use Apex, and need to use SOQL only, then binding is not allowed. Which means you cannot use system.now(); With that in mind, you can use Date Literals, such as YESTERDAY, TODAY, TOMORROW, and so on. Eg: SELECT CreatedDate FROM Account WHERE CreatedDate <= TODAY SELECT CreatedDate FROM Account WHERE CreatedDate <= YESTERDAY


3

You can't. The order of query results is undefined if you don't use an explicit ORDER BY clause: You can use ORDER BY in a SELECT statement to control the order of the query results. There is no guarantee of the order of results unless you use an ORDER BY clause in a query. ORDER BY sorts by the value of the field, not by the order of specified ...


3

Yes , we can only define one primary key but you can define unique indexes in your table which can also work like primary key in that case they should have unique values .


3

A possible cause would be if the field Transaction_Date__c is a DateTime field, assigning a Date to it would set the hours/minutes/seconds to zero, and then the automatic timezone handling for your User would subtract (or add) hours and so move the Date part to the previous day. A quick fix for that would be: transact.Transaction_Date__c=DateTime.Now(); ...


3

Simpler way? well yes and no. We have Database.getUpdated method that returns Id of records updated in a particular time span. It takes sObject Type , start date and end date as arguments and returns ID of updated record. The tricky bit is not every object is supported, so you have add ignore list or some custom logic for objects not supported by ...


3

You wouldn't use a query for this, but rather the DescribeSObjectResult and DescribeFieldResult classes. Schema.SObjectType.<Sobject API Name>.fields gives you a Map<String, Schema.SObjectField> containing the field tokens for all of the fields on the object You can then iterate over those Schema.SObjectField instances, and get the ...


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