+ Start a Discussion
Nithyanandha NimmalaNithyanandha Nimmala 

I came across an error in which I got in a record triggered flow Too many SOQL Queries). It is a. In which a "get record" element which queries contacts by comparing the ids present in another list and having couple of other conditions which checks whether some fields should not be null. The flow element is not present in any loops. can you please tell me in which other direction i can look to solve this issue
Best Answer chosen by Nithyanandha Nimmala
Arun Kumar 1141Arun Kumar 1141

Hi Nithyanandha,

In order to resolve a "Too many SOQL Queries" problem in a record-triggered flow, you can try the following strategies:

1. Bulkification: Make sure your flow is set up to effectively handle bulk records. You have used more SOQL searches than allowed, according to the error notice. The number of inquiries may exceed the governor restrictions if the flow is simultaneously being initiated for several records. Check the flow's architecture to make sure it can manage large numbers of records and reduce the amount of SOQL queries issued.

2. Query Optimisation: Examine your flow's SOQL queries to see if they can be made more efficient. Find ways to slash the amount of inquiries or combine them into one more effective query. If applicable, take into account relationships or aggregate inquiries.

3. Review the criteria used in the "get record" element when considering filtering and filtering logic. To decrease the amount of records obtained, see whether the criteria may be improved or made simpler. Make sure the criteria are limited and prevent the querying of a huge number of records.

4. Check the running user's access to the records being requested to see whether it is suitable. Make sure the user has read access to all required fields and objects. Check to see if there are any record-level security settings or sharing restrictions that might affect the records you've collected.

5. Recursive Calls: Your flow may result in recursive calls and excessive SOQL searches if it contains any subflows or calls other processes that might possibly cause the same flow to be triggered again. Make sure your flow is not self-triggering or becoming stuck in a loop.

6. Other Flow Elements: Examine the other components to make sure they aren't leading to more requests. Check to see whether any record update or creation components, for instance, are running extraneous queries.

7. External Data Sources: Ensure that the external data sources are correctly set and optimised if you're utilising External Objects to query data from external systems. The SOQL query restrictions may also apply to external queries.

You should be able to find the possible reasons of the "Too many SOQL Queries" error by looking into these areas, and you can then make the appropriate modifications to fix the problem.

Thanks,

 

Amy StruckmeyerAmy Struckmeyer 
My org's inside sales team is requesting that a task is assigned to them to follow up with a customer 30 days after they Close Won an Opportunity.

Is this possible? If so.. how? My org is already developed/in use. 
(Would need step by step instructions..)

I'm an "accidental admin" so even through I've Googled this, a lot, I'm still not finding exactly what I need. 
Best Answer chosen by Amy Struckmeyer
SwethaSwetha (Salesforce Developers) 
HI Amy,
You can try a visual flow or use a trigger for your requirement.

Below is the trigger code that I've tested on my org
trigger OpportunityTrigger on Opportunity (after update) {
    public static void createFollowUpTask(List<Opportunity> opps) {
        List<Task> followUpTasks = new List<Task>();
        
        for (Opportunity opp : opps) {
            if (opp.StageName == 'Closed Won') {
                Task followUpTask = new Task();
                followUpTask.Subject = 'Follow-up with Customer';
                followUpTask.WhatId = opp.Id; // Link task to the Opportunity
                followUpTask.ActivityDate = opp.CloseDate.addDays(30); // Set due date 30 days after Close Date
                followUpTask.OwnerId = '0056F00000DvDyj'; // Set the ID of the inside sales team member
                followUpTasks.add(followUpTask);
            }
        }
        
        if (!followUpTasks.isEmpty()) {
            insert followUpTasks;
        }
    }
    
    // Trigger entry point
    if (Trigger.isAfter && Trigger.isUpdate) {
        createFollowUpTask(Trigger.new);
    }
}

You can customize this as needed. Please test this in your sandbox and then deploy it to production.

If this information helps, please mark the answer as best. Thank you
Mirelis SotoMirelis Soto 

Hello, I have a picklist field (Not a multi-select just regular), I want a checkbox formula field to mark true when any of the many values is selected. 

For example field called Color__c. 

IF(ISPICKVAL( Color__c , 'Red') || ISPICKVAL( Color__c , 'Blue') || ISPICKVAL( Color__c , Yellow') || ISPICKVAL( Color__c , 'Green')  || ISPICKVAL( Color__c , 'Brown) || ISPICKVAL( Color__c , 'Pink') || ISPICKVAL( Color__c , 'Magenta' || ISPICKVAL( Color__c , 'Orange')|| ISPICKVAL( Color__c , 'Purple')  

 

But this is not working is missing something. I am new to formulas and I am not sure how to proceed from here. Any help is greatly appreciate it. 

Best Answer chosen by Mirelis Soto
SubratSubrat (Salesforce Developers) 
Hello ,

Your formula appears to be missing closing single quotes for some of the color values. Here's the corrected formula:
 
IF(ISPICKVAL(Color_c, 'Red') || ISPICKVAL(Colorc, 'Blue') || ISPICKVAL(Colorc, 'Yellow') || ISPICKVAL(Colorc, 'Green') || ISPICKVAL(Colorc, 'Brown') || ISPICKVAL(Colorc, 'Pink') || ISPICKVAL(Colorc, 'Magenta') || ISPICKVAL(Colorc, 'Orange') || ISPICKVAL(Color_c, 'Purple'), TRUE, FALSE)


This formula uses the ISPICKVAL function to check if the picklist field Color__c has any of the specified values selected. If any of the conditions evaluate to true, the formula returns TRUE; otherwise, it returns FALSE. You can replace TRUE and FALSE with any desired values depending on your requirements.


If this helps , please mark this as Best Answer.
Thank you.
Nila Das 3Nila Das 3 

(AND(Number_of_Attachments__c == 0,$Profile.Name  <>  'YouGov Sales + YouGenius', ISPICKVAL(StageName, 'CLOSED WON')))  ||  

IF(REGEX( YouGenius_Sales_Contract__c ,'^((http|https)://)??(www[.])??([a-zA-Z0-9]|-)+?([.][a-zA-Z0-9(-|/|=|?)??]+?)+?$'),FALSE, IF(ISPICKVAL( YouGenius_Contract_Status__c  , 'SIGNED'),ISPICKVAL(StageName, 'CLOSED WON'),FALSE) )

Error message: Opportunity can be closed won only if it has atleast an attachement and youGenius Sales Contract is populated with a URL AND YouGenius Contract Status = SIGNED

My only concern is, this validation rule should be applicable only to one profile "YouGov Sales + YouGenius". Rest of the users from other profile should not see face this criteria.

Best Answer chosen by Nila Das 3
SwethaSwetha (Salesforce Developers) 
HI Nila,

Try below
AND(
  OR(
    Number_of_Attachments__c == 0,
    $Profile.Name <> 'YouGov Sales + YouGenius',
    ISPICKVAL(StageName, 'CLOSED WON')
  ),
  NOT(
    $Profile.Name = 'YouGov Sales + YouGenius'
    && REGEX(YouGenius_Sales_Contract__c, '^((http|https)://)??(www[.])??([a-zA-Z0-9]|-)+?([.][a-zA-Z0-9(-|/|=|?)??]+?)+?$')
    && ISPICKVAL(YouGenius_Contract_Status__c, 'SIGNED')
  )
)

Make sure to replace 'YouGov Sales + YouGenius' with the actual name of the profile you want to apply this rule to.

If this information helps, please mark the answer as best. Thank you
Zac RedmondZac Redmond 
We are utilizing Salesforce Chat with an Embedded Service Deployment and an Einstein Bot. We can see in the Embedded Services code there is a parameter for checking if an agent is unavailable. Is there a parameter for when a chat has ended (either by the agent or the customer)? Thanks
Best Answer chosen by Zac Redmond
SwethaSwetha (Salesforce Developers) 
HI Zac,

Incase of Chat Event Notifications, see https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_chat_events.htm

onChatEndedByAgent : Fired when the agent ends the chat.
onChatEndedByChasitor : Fired when the chat visitor ends the chat.
onChatEndedByChatbot :Fired when the bot ends a chat.


Related: https://salesforce.stackexchange.com/questions/355669/trying-to-add-additional-behavior-in-post-chat-for-embedded-services

If this information helps, please mark the answer as best. Thank you
Best Answer chosen by Saravana Ravikumar
Arun Kumar 1141Arun Kumar 1141
Hi Saravana Ravikumar,

In Salesforce, there are different technologies and components used for creating and managing flows, which are declarative tools for building business processes. Let's explain each of them:

1. Lightning Flow: Lightning Flow is a feature in Salesforce that allows you to automate business processes by creating flows with a visual designer. It provides a drag-and-drop interface for defining the flow logic, integrating with data sources, and guiding users through a series of screens or steps. Lightning Flow is typically used to create dynamic and interactive experiences for users.

2. lightning:flow (Lightning Component): The `lightning:flow` component is a Lightning component that allows you to embed a Lightning Flow within a Lightning App or Lightning Community. By adding the `lightning:flow` component to your Lightning components, you can include flows directly within your application's user interface.

3. aura:flow (Aura Component): The `aura:flow` component is an Aura component used to embed a Visual Workflow (previously known as Flow) into a Lightning Aura Component. Aura components are part of the Aura framework, the predecessor to Lightning Web Components (LWC). The `aura:flow` component is used in Aura-based applications to incorporate Visual Workflows.

4. aura-flow (Aura component event): The `aura-flow` event is an event fired by a Visual Workflow (previously known as Flow) to communicate with an Aura component that has embedded the flow using the `aura:flow` component. It allows the Aura component to receive and handle events or data from the embedded flow.

if this helps you, pleasemark it as a best answer
Thanks!
 
Best Answer chosen by Saravana Ravikumar
SubratSubrat (Salesforce Developers) 
Hello Saravana ,

Both the public property and custom event approaches can be used to pass a string value from a parent Lightning Web Component (LWC) to a child LWC.

Public Property: With this approach, you can define a public property in the child component and bind it to a value in the parent component. Here's an example:
Parent Component HTML:
<template>
  <lightning-card title="Parent Component">
    <c-child-component child-property={parentProperty}></c-child-component>
  </lightning-card>
</template>
Parent Component JavaScript:
import { LightningElement } from 'lwc';

export default class ParentComponent extends LightningElement {
  parentProperty = 'Hello from Parent';
}
Child Component JavaScript:
import { LightningElement, api } from 'lwc';

export default class ChildComponent extends LightningElement {
  @api childProperty;
}
In this example, the parentProperty value is passed to the childProperty property in the child component using the @api decorator.

----------------------------------------------------------------------------------------------------

Custom Event: This approach involves creating a custom event in the parent component and dispatching it with the string value as the event payload. The child component can then handle the event and retrieve the value. Here's an example:
Parent Component HTML:
<template>
  <lightning-card title="Parent Component">
    <button onclick={sendValueToChild}>Send Value to Child</button>
  </lightning-card>
</template>
Parent Component JavaScript:
import { LightningElement } from 'lwc';

export default class ParentComponent extends LightningElement {
  sendValueToChild() {
    const event = new CustomEvent('sendvalue', {
      detail: 'Hello from Parent'
    });
    this.dispatchEvent(event);
  }
}
Child Component HTML:
<template>
  <lightning-card title="Child Component">
    <p>{childProperty}</p>
  </lightning-card>
</template>
Child Component JavaScript:
import { LightningElement, api } from 'lwc';

export default class ChildComponent extends LightningElement {
  @api childProperty;

  connectedCallback() {
    this.addEventListener('sendvalue', this.handleValueFromParent);
  }

  handleValueFromParent(event) {
    this.childProperty = event.detail;
  }
}
In this example, the sendValueToChild method in the parent component dispatches a custom event named 'sendvalue' with the string value as the detail property. The child component listens for this event using addEventListener and updates its childProperty value accordingly.

If this helps , please mark this as Best Answer.
Thank you.
panu babupanu babu 
Hi, I would like to know if a timer can be included in salesforce chat window when an agent is chatting with a customer. The timer should get reset after every chat message. This will allow the agent or the customer know how long they are waiting since the last conversation.  Please advice. 
Best Answer chosen by panu babu
SubratSubrat (Salesforce Developers) 
Hello Panu ,

Apoligies , but this functionality is still under Idea Exchange -> https://ideas.salesforce.com/s/idea/a0B8W00000GdewiUAB/live-agent-chat-timer-to-show-cumulative-time-of-chat-vs-real-time

I would request you to upvote this idea , so that you can get update on this.

Please mark this as Best Answer for closing this loop and keeping our Dev Forum Community clean.

Thank you.
Pierre Crouzet 10Pierre Crouzet 10 
Hi everyone,
The Salesforce Gmail integration is no more working with the clients:hasEventContext interface when using aura component, since this week it doesn't fill the start and end field anymore on the dates object.
Does anyone experience the same issue and find a solution ?
The standard Log event is still working and event are created with dates.
Regards,
Pierre
Best Answer chosen by Pierre Crouzet 10
SwethaSwetha (Salesforce Developers) 
Update: The salesforce product team has filed an internal bug #W-13554887.There is no update on the ETA yet but I will update this thread as I have more info. The cause for this behavior is identified as the changes that Google is making to Google Calendar. 

Please mark the answer as best to close the thread so it can help others too.

Thank you
Swetha Maddali
Senior Support Engineer
Salesforce.com
Naureen Hameed 39Naureen Hameed 39 
Hello working on a Trigger with three requirements: 

 A custom Object Evalutation "Evaluations__c" has a master detail relationship to "Opportunity".
Opportunity has a custom "Primary_eval_owner__c" field.

Requirements: 
1) When an Evaluation is created, Trigger should check the "Primary_eval_owner__c" field on Opportunity and if filled, assign Evaluation to existing eval owner.
2)If "Primary_eval_owner__c" is null, assign it to next owner in round robbin.
3)Update " "Primary_eval_owner__c" with the name of the new User assigned so subsequent Evaluations can be assigned to the same owner. 
4) We have two Users that need to round robbin.
5) Addditionally, I have created this trigger for assignment part (requirement 2) but the 4th last line is giving the error: "Field is not writable: Evaluations_c.Round_Robin_ID__c"

Thank you in advance. 

Trigger: 

trigger SCRoundRobinTrigger on Evaluations__c (before insert) {
    if(Trigger.isBefore){
        Double roundRobinValue = 1;
        List<Evaluations__c> Evalist = [SELECT Id, Round_Robin_ID__c, CreatedDate FROM Evaluations__c where Round_Robin_ID__c  != null
                                 order by CreatedDate desc limit 1];
        if(Evalist!= null && Evalist.size()>0){
            roundRobinValue = Evalist[0].Round_Robin_ID__c;
        }
       
        
        for(Evaluations__c c: Trigger.New){
            system.debug('###Round Robin Value : '+roundRobinValue);
            if(roundRobinValue == 2){
                roundRobinValue = 1;
                c.OwnerId = '0054U000009JgsIQAS';
            }
            else{
                roundRobinValue++; 
                c.OwnerId = '0054U000009J81gQAC';
            }
             c.Round_Robin_ID__c = roundRobinValue;
        }
    }
}
Best Answer chosen by Naureen Hameed 39
SubratSubrat (Salesforce Developers) 
Hello Naureen ,

The error "Field is not writable: Evaluations_c.Round_Robin_ID_c" occurs because you are trying to update the "Round_Robin_IDc" field on the "Evaluations_c" object, but it seems that this field is not editable.

To address your requirements, you can modify your trigger code as follows:
 
trigger SCRoundRobinTrigger on Evaluations__c (before insert) {
    if (Trigger.isBefore) {
        // Get the opportunity IDs for the evaluations being inserted
        Set<Id> opportunityIds = new Set<Id>();
        for (Evaluations__c eval : Trigger.New) {
            if (eval.Opportunity__c != null) {
                opportunityIds.add(eval.Opportunity__c);
            }
        }
        
        // Query the opportunities with primary_eval_owner__c and order them by created date
        List<Opportunity> opportunities = [
            SELECT Id, Primary_eval_owner__c
            FROM Opportunity
            WHERE Id IN :opportunityIds
            ORDER BY CreatedDate ASC
        ];
        
        // Get the next round robin owner ID
        String nextOwnerId;
        if (opportunities.isEmpty() || opportunities[0].Primary_eval_owner__c == null) {
            // If no primary_eval_owner__c or no opportunities, assign to the first user
            nextOwnerId = '0054U000009JgsIQAS';
        } else {
            // Otherwise, assign to the second user
            nextOwnerId = '0054U000009J81gQAC';
        }
        
        // Assign the evaluations to the owners and update primary_eval_owner__c
        for (Evaluations__c eval : Trigger.New) {
            eval.OwnerId = nextOwnerId;
            if (eval.Opportunity__c != null) {
                Opportunity opportunity = opportunities.remove(0);
                opportunity.Primary_eval_owner__c = nextOwnerId;
                nextOwnerId = (nextOwnerId == '0054U000009JgsIQAS') ? '0054U000009J81gQAC' : '0054U000009JgsIQAS';
            }
        }
    }
}
If this helps , please mark this as Best Answer.
Thank you.