Skip to main content

#Apex54 discussing

Short gist to put above the question

One thing I would not include yet

Don't state “Amazon Connect caused the incident.” We haven't proved that. Phrase it as a lead under investigation, which will make the Trailhead question much more credible and technically precise.

 

 

#Salesforce Developer  #Salesforce  #Apex  #Trailhead

0/9000

Hi All,

I am getting error:

"Method does not exist or incorrect signature: void returnAverageSum(List<Opportunity>) from the type PracticeApex" . Kindly help me in resolving above error.

Here is my code

public class PracticeApex{

    public static void retrunAverageSum(List<Opportunity> ol){

        Integer avg=0;

        Integer sum=0;

        Integer size= ol.size();

        for(Opportunity o: ol){

           sum=sum+o.Amount.IntValue();           

        }

        avg=sum/size;

    System.debug(avg);

    }

    }

from Dev Console:

PracticeApex pa=new PracticeApex();

List<Opportunity> opp=[Select Id, Amount from Opportunity];

pa.returnAverageSum(opp);
2 answers
  1. Oct 9, 2023, 6:16 AM

    Hi Vishal,

    1. Typo Mistake : Your method name is retrunAverageSum and you are calling returnAverageSum in Dev Console.

    2. Remove static keyword from method.

    Hope this will help.

    Thanks!
0/9000

Hi everyone,

I need an architectural sanity check on a security requirement. I want to avoid hitting platform limits down the road and would appreciate some feedback on whether this can be safely achieved using Schedule-Triggered Flows or whether Scheduled Batch Apex would be required.

Context

  • We are changing the Organization-Wide Defaults (OWD) of the standard Quote object from Controlled by Parent to Private.
  • We receive an integration feed from an external system that creates or updates up to approximately 80 Quotes per Account per day. Quotes can also be created manually in Salesforce.
  • Quotes contain two custom Account lookups: Sold-To and Bill-To.
  • We have both Quotes with and without Opportunities.

Requirement

  • The Account Owner of the Sold-To Account and the Account Owner of the Bill-To Account must have Read-Only access to the related Quote.
  • When the Account Owner changes, access to the related Quotes must be updated accordingly, including removing the previous owner's access and granting access to the new owner.
  • The required access is managed through QuoteShare records with RowCause = Manual.

Architectural Question

Given the expected Quote volume and the need to automate the insertion and cleanup of QuoteShare records following Account ownership changes:

  • Is this approach feasible using a standard Schedule-Triggered Flow, or would Scheduled Batch Apex be required to ensure scalability and avoid governor limits?
  • What would be the cleanest architectural pattern for handling the cleanup and creation of Manual QuoteShare records when Account ownership changes?

Thanks for your guidance!

 

 

@Salesforce Administrators & Developers, @Salesforce Administrators and Developers, @APAC Architects, @Data Quality & Management

 

 

#Trailhead Challenges  #Salesforce Developer  #Salesforce Admin  #Salesforce  #Flow  #Apex

3 answers
  1. Sep 26, 8:40 PM

    @sakshi nagpal

    , would you still recommend using APEX instead flow if the volume of quotes is of up to 80 per day approx. in general and not per account?. 

    @Debarshi Bagchi, sorry if I ask you, I would appreciate any guidance in this sense,

0/9000
Hi All, 

I have tried to delete the record from VoiceCallRecording in the execute anonymous to test this functionality so that later on I can put the same in Apex class.

I am the owner of voicecall record.

Here is the below code snippet.

List<VoiceCallRecording> vcr = [SELECT Id, Name, VoiceCallId FROM VoiceCallRecording where VoiceCallId = 'SomeIdOfVoiceCall'];

delete vcr.get(0);

and when I execute this, I get error like DML operation Delete not allowed on VoiceCallRecording

As per documentation of the VoiceCallRecording says that the delete() is allowed. Could anyone pls guide me through this, is there any permission set that needs to be enabled or anything that I am missing

url of the documentation Link (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_voicecallrecording.htm)
2 answers
0/9000

 I need to automatically create a Chatter post on a Case whenever its pending approval request is reassigned to another user using the standard Reassign action. Since triggers and record-triggered flows aren't supported on ProcessInstanceWorkitem, and the Case itself doesn't change, I'm not sure how to capture this event. Has anyone solved this, whether with scheduled polling, a custom reassign component, or another approach? Any suggestions or sample code would be appreciated.  

 

#Trailhead  #Salesforce Developer  #Salesforce Admin  #Salesforce  #TrailblazerCommunity  #Sales Cloud  #Apex  #Salesforcecommunity  #Salesforce_developer

2 answers
  1. Sep 25, 8:00 AM

    You’re correct that there isn’t a direct trigger point here. ProcessInstanceWorkitem doesn’t support Apex triggers or record-triggered flows, and reassigning the approval doesn’t update the Case itself. 

     

    If you need to keep the standard Reassign action, I’d handle it with scheduled Apex:

    1.  Run a scheduled job every few minutes. 
    2.  Query new ProcessInstanceStep records where StepStatus = 'Reassigned'. 
    3.  Use ProcessInstance.TargetObjectId to identify the related Case. 
    4.  Query the pending ProcessInstanceWorkitem for that process instance to get the newly assigned ActorId. 
    5.  Insert a FeedItem with the Case ID as ParentId. 
    6.  Store the processed ProcessInstanceStep.Id in a small custom log object with a unique/external-ID field. 
    7.  Skip any step already in that log so rerunning the job can’t create duplicate Chatter posts. 

    I’d also test it by reassigning the same approval twice and then running the job twice. The expected result should be two Chatter posts total, with no additional posts from the second job run. 

     

    If real-time posting is absolutely required, the other option is to replace the standard Reassign experience with a custom Flow/LWC backed by Apex. That custom action would update ProcessInstanceWorkitem.ActorId and create the Case FeedItem in the same transaction. But the existing standard Reassign action can’t be intercepted directly.

0/9000

Hi everyone,

I have a question regarding the “Create Quotes without Opportunities” feature and a potential future requirement involving Orders.

 

After enabling the “Create Quotes without Opportunities” feature, Salesforce automatically provides the QuoteAccountId field on the Quote object. For Quotes created without an Opportunity, the Account relationship is stored in QuoteAccountId, while the standard AccountId is not populated.

 

Would it be technically possible to populate the standard AccountId field with the value from QuoteAccountId

for Quotes created without an Opportunity?. 

 

The reason for considering this is that Orders will be used in the future, and the standard Account relationship may be required for the Order process.

Would populating AccountId = QuoteAccountId be a supported and recommended approach, or are there any Salesforce limitations or implications we should consider when working with Quotes without Opportunities? or any workaround?.

Thanks for your guidance! 

 

@Salesforce Administrators & Developers, @Salesforce Administrators and Developers, @APAC Architects, @Data Quality & Management

 

 

#Trailhead Challenges  #Trailhead  #Salesforce Developer  #Salesforce Admin  #Salesforce  #Flow  #Data Management  #Apex  #Sales Cloud

2 answers
  1. Sep 24, 3:17 PM

     

    Short answer: you generally cannot (and do not need to) write QuoteAccountId into the standard Quote.AccountId field. On the Quote object, AccountId is a system-derived, read-only reference that Salesforce fills from the related Opportunity's Account. It is not createable/updateable through the UI, Flow, Apex or the API, so an update like AccountId = QuoteAccountId will be rejected or ignored. For quotes created without an Opportunity, QuoteAccountId (label "Account for Quote") is the field Salesforce intends you to use as the account relationship. 

     

    For your future Order process this is already covered: Salesforce's documentation for quotes without opportunities says associating the quote to an account is optional but recommended, because an account is required to convert the quote to an order. When you create an Order from such a quote, the account comes from the quote's account (QuoteAccountId), so you don't need Quote.AccountId populated. 

     

    Practical recommendations: 

    1. Make QuoteAccountId required (validation rule, e.g. ISBLANK(OpportunityId) && ISBLANK(QuoteAccountId)) so every quote can be turned into an Order. 

    2. After enabling the feature, open Object Manager > Quote > Fields > Account for Quote and grant field-level security to your profiles/permission sets. It is hidden by default, which is why it often looks unavailable in Flow, reports and Apex. 

    3. In reports, flows, sharing logic and Apex, use one source of truth, for example a formula field BLANKVALUE(QuoteAccountId, Opportunity.AccountId), so logic works for quotes with and without an Opportunity. 

    4. If you create Orders yourself via Flow/Apex (rather than the standard Create Order action), set Order.AccountId = Quote.QuoteAccountId and Order.QuoteId = Quote.Id. 

     

    References: 

    Enable Quote Creation Without a Related Opportunity:

    https://help.salesforce.com/s/articleView?id=sales.cpq_quotes_without_opportunities.htm&type=5

     

    Release note, Create Quotes Without a Related Opportunity:

    https://help.salesforce.com/s/articleView?id=release-notes.rn_sales_quotes_without_opportunities.htm&release=244&type=5

     

    Quote object reference:

    https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_quote.htm

     

     

    Assumption: the statement that Quote.AccountId is read-only is based on the Quote object reference field properties and commonly reported org behaviour; please confirm in a sandbox (e.g. attempt the update in a Flow or Developer Console) before designing around it.

0/9000

we have a dependent picklist in LWC and we get the value from standard getPicklistValue method, but when user language is non-english and we have a translation for the picklist vlaue, the picklist value won't shown in the front end.  

But if the translated value is same as English, it will be shown in the front end.  

 

Dependent picklist not shown in LWC page when user has a non-English language.

 

I also asked AI and it say:  

When assembling picklist value sets in the UAT sandbox (Winter '27) using the UI-API in a non-default language, values with translated entries are incorrectly discarded—this is a platform regression, not a data or configuration issue. Production is currently running an older version and is therefore safe, but the issue will inevitably reoccur the moment production is upgraded to Winter '27. 

 

So I want to know if this is a salesforce Known issue or not?  

 

 

#Trailhead Challenges  #Salesforce Developer  #TrailblazerCommunity  #Apex

2 answers
  1. Sep 22, 11:14 AM

    Hi @Bruce Wang

    -  Its  likely due to translated labels being used for dependency mapping.  

    Use the picklist API value for controllerValues matching, and use label only for displaying the value.  

    controllerValue === index
0/9000

Hello !  

 

My business would like a way for a Financial record to be analyzed (questions and text-box answers) by multiple users that can see each others analyses on

 the same screen/record that they are performing the analysis on. 

 

So far I have two ideas for doing so. 

 

1. Have all the analysts work on the same record and let Salesforce tell the user that they can't edit it because someone else is editing it. 

2. Have the analysts work on different records, and each time they save their analysis, have a trigger send that analysis to a separate field in all related analyses. 

 

The first has the concurrency issue and the second solution sounds a little rough as we have a Reviewer that checks over all of the analyses and there'd be multiple places he could go to see everyone's work. 

 

Does anyone have a better idea or improvements on mine ? 

 

Thank you greatly for your time ! 

 

#Salesforce Developer  #Apex  #Data Management  #Salesforce  #Salesforce Admin

2 answers
  1. Sep 15, 8:12 AM

    Hi Sabeer, 

     

    Both of your ideas are solving this the hard way — the actual fix is a data model change, not a concurrency workaround. 

     

    Best approach: create a child object (e.g., "Financial Analysis") related to the Financial record via a Lookup (or Master-Detail if you want rollups/cascade delete). Each analyst creates their own Financial Analysis record against the same parent Financial record — one record per analyst, not one shared record. 

     

    Why this solves everything you listed: 

     

    1. No concurrency/locking issue at all — each analyst is editing their own distinct record, never the same row, so there's no "someone else is editing this" conflict. 

     

    2. Everyone still sees everyone else's work on the same screen — add a related list (or better, a Lightning page component/Dynamic Related List) showing all Financial Analysis child records on the parent Financial record page. All analysts land on the same parent record and see every analysis in that related list in real time (or on refresh). 

     

    3. One place for the Reviewer — the Reviewer opens the single parent Financial record and sees all analyses in that one related list, rather than hunting across multiple separate records like your second idea would require. You can even add a Reviewer-only "Review Status" or "Approved" field directly on each child Analysis record so they can mark each one off in the same place. 

     

    Optional enhancements once the base model is in place: 

    - Use Record-Triggered Flow or a validation rule to prevent duplicate Analysis records per analyst per Financial record (one analyst, one analysis, enforced by a formula/validation on a unique key like Analyst + Financial Record). 

    - If you want a roll-up summary (e.g., "X of Y analysts submitted"), a Master-Detail relationship gives you native Roll-Up Summary fields for that. 

    - If the Reviewer needs a consolidated read-only view rather than scrolling a related list, a simple Lightning Web Component pulling all child records into a table/grid on the parent page works well too. 

     

    This pattern (one child record per contributor, rolled up to a shared parent) is the standard Salesforce way to handle "many people annotate the same thing" without ever touching record locking.

0/9000

Hi Everyone,

I have a question regarding sending dynamic emails from a Flow using Email Templates.

In my current Flow, I have configured dynamic emails using an Email Template for Leads, and it is working as expected. However, after Lead conversion, I need to send an email either to the Opportunity Owner or to an email address stored in a custom field on the Opportunity.

Is it possible to send dynamic emails using an Email Template for the Opportunity object directly from Flow, without using Apex?

If anyone has implemented this solution or knows the best approach, please share your insights.

Thanks in advance! 😊 

 

#Salesforce Developer  #Trailhead Challenges  #Trailhead  #Sales Cloud  #Flow  #Apex

1 answer
  1. Sep 11, 6:24 PM

    @durgam santhosh

     

     

    Yes - the native no-Apex route is an Email Alert (the core 'Send Email' Flow action won't render a template's merge fields). Create an Email Alert on Opportunity (Setup > Email Alerts) that uses your Opportunity Lightning template, then call it from your record-triggered Flow as an Action - the alert sets the triggering Opportunity as the Related To, so all your Opportunity merge fields resolve. 

     

    For recipients you can pick Opportunity Owner directly; to send to that custom email field it has to be an Email-type field, then it shows up under Recipient Type 'Email Field'. 

     

    If this helps, please mark it as the Best Answer so it helps the next person - thanks!

0/9000

🎥 I've started a YouTube channel — SalesforceDevDaily! 

 

Sharing the concepts, hacks, and lessons I've learned working as a Salesforce Developer — Apex, LWC, and real project tips. 

Channel Link:-

https://youtube.com/@salesforcedevdaily?si=33wpFFurKxhWvBEI

 

 

Subscribe and let's learn together! 🚀 

#Salesforce #Apex #LWC #Trailblazer

4 comments
  1. Sep 11, 1:47 PM

    Congratulations on starting SalesforceDevDaily! 🎉 This is a great initiative, especially for developers looking to strengthen their Apex and LWC skills with practical, real-world insights. 

    Looking forward to learning from your content and seeing the upcoming videos. Wishing you lots of success with the channel! 🚀👏 

0/9000