Hot answers tagged

4

You're using the wrong index variable. opp.Highest_Priced_Competitor__c = competitors.get(highestPricePosition); opp.Highest_Price__c = competitorPrices.get(highestPrice); The second line should also be using highestPricePosition, which is an Integer- or simply assigning highestPrice directly, since you do gather that value in your loop. Arrays ...


3

If the lock from the first user gets released within 5 seconds, will the second user get access to the same record even though now the status of the record is 'unavailable'? I had to answer the same thing for some of my own architecture, and I can definitively say that if your other operation changes the Status__c to no longer equal 'Available', then your ...


3

You can't use Apex binds in the SELECT clause. They're supported in: The search string in FIND clauses. The filter literals in WHERE clauses. The value of the IN or NOT IN operator in WHERE clauses, allowing filtering on a dynamic set of values. Note that this is of particular use with a list of IDs or Strings, though it works with lists of any ...


2

In JavaScript, you can use the method String.prototype.includes, or String.prototype.match (or several others). String.contains is an Apex method (and Java, and other languages), but JavaScript does not have such a method. Alternatively, you can use a RegExp. includes if(result.getState() === 'SUCCESS' && resultApex.includes('Successfully')) { ...


2

Putting Security.stripInaccessible in the mix addresses most (all?) object and field level filtering, though the class should also be with sharing to make sure row level sharing rules apply: @AuraEnabled(cacheable=true) public static List<Opportunity> getRecords() { List<Opportunity> opps = [SELECT ... FROM Opportunity WHERE ...]; ...


2

Well, I solved it and it turned out to be profile related, but the solution is mystifying to me, very unsatisfactory. In the sandbox in which I develop, the only profile that has access to the class XYZ is sysadmin. Other users can use the Apex class, because it is not accessed directly, but via the JS code in my LWC. But on the QA sandbox, I had to add ...


2

You can provide a method that returns fields in a Map and a method that checks the map for null fields: class Wrapper{ String name {get;set;} Integer age {get;set;} EduWrap edu {get;set;} public Map<String, Object> toMap() { return (Map<String, Object>) JSON.deserializeUntyped(JSON.serialize(this)); } public ...


1

The Scheduled Action is itself a DML transaction. The "zero" used DML shown is because the top level DML in a transaction is "free" (it never counts towards the limits). Try inserting a record against an object withno triggers or actions, you'll see the same type of log.You need to instead use a future or Queueable class to execute asynchronously.


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