@venkateswarlu Allipudi
Check the below trigger :
trigger PreventCaseDeletion on Case (before delete) {
// Set to store IDs of Cases being deleted to minimize the query scope
Set<Id> caseIdsBeingDeleted = Trigger.oldMap.keySet();
// Query to find Cases that are being deleted and are related to both an Account and a Contact
List<Case> casesWithAccountAndContact = [
SELECT Id
FROM Case
WHERE Id IN :caseIdsBeingDeleted
AND AccountId != null
AND ContactId != null
];
// Set to store the IDs of Cases that meet the criteria for prevention
Set<Id> preventDeletionCaseIds = new Set<Id>();
for (Case c : casesWithAccountAndContact) {
preventDeletionCaseIds.add(c.Id);
}
// Loop through the Cases in Trigger.old to find matches and prevent deletion
for (Case c : Trigger.old) {
if (preventDeletionCaseIds.contains(c.Id)) {
// Prevent deletion by adding an error to the Case record
c.addError('Cannot be deleted because it is related to both an Account and a Contact.');
}
}
}
#Record-Triggered0 discussing
- Recent Activity
- Created Date
- Recommended
- All Questions
- Questions with an Accepted Answer
- Unanswered Questions
- Questions with No Accepted Answer
Did you know you can apply Validation Rules in a Approval Process using a Custom Error Message in Flow?
This can prevent a invalid record from being submitted for Approval and instruct the users how to remedy the problem.
Find out more in this how-to video; https://youtu.be/XhAO2emDOdA?si=HQOKzbC0g3a_lF2-
#Flow #ApprovalProcess #Record-Triggered #Salesforce #Salesforce Developer #Salesforce Admin #TrailblazerCommunity #CRM Configuration
Hello Community! Im stuck and need your help!
I have a custom object (+tab) that allows users to create records
On this object there is a lookup field (for Site Name) to the Site Object
I want to prevent users from being able to create multiple records with the same Site Name
Ive created a Checkbox on my object
Ive created a Validation Rule pointing to the checkbox
Ive created a Record Triggered Flow that contains
- Get Records
- Decision
- and Assignment elements
I am not even able to create a single record without my error message popping up, as I believe its treating my Site Name lookup value as "already exists" (which it does it its own object) but NOT in my custom object.
Anyone know how to make my flow / rules look for duplicate records ONLY on my custom object?
Hope this makes sense.
Thanks,
Nick
Feb 29, 2024, 9:07 PM @Priyanshu Gupta thanks for the help! Ive tried many variations of this kind of validation rule ALL with syntax errors. Im starting to think that my Site Name look up fields and Site Name formula fields are causing the issue. Im trying to look at the formula field of current records to see if there are existing values.
Here are some example value names to help with another try!
object name = site support details
lookup field = Site Name
formula filed = SSD Site (this field populates what the user selects from the site name look up field)
For context of myself: I have never built a flow before (besides following tutorials). I feel like I have a general idea but am also all over the place with my thoughts on how to build this flow. I am looking for advice/ guidance on whether this flow is possible, if there is a way to simplify the flow, if I am missing resources/elements or if there are other simpler solutions I am overlooking.
The flow itself will be gathering records related to a contact's account's assigned user(s) and contact's account's assigned territory/territories then updating the record of the contact that triggered the flow. I plan to use this information to set criteria for sending email alerts or setting an approval process for contacts moved based on the territory of the account the contact was in and to the assigned users of the territory of the account the contact was in. I am attaching a PDF file that I have been using to brainstorm how I will create this flow and gives more context to why I am creating the flow and what issue I am trying to solve. Any guidance is greatly appreciated! Thank you!
Feb 29, 2024, 4:33 PM Another thought I had is using a screenflow to gather information rather than creating a flow to populate a field then using a decision element to create different pathways based on the information gathered from the rep. Such as if I could get the rep to select from a picklist the assigned user/assigned users in the territory of the account they are moving contact from to send email to the users selected. Also do not know if this is possible but think it could simplify the flow if so.
Hi everyone,
I've having trouble in testing my Record-Triggered flow using the Tests feature, that I cannot overcome.
In summary, when I run with the Debug, everything is fine, and flow runs until the end.
However, when I run with a Test (either a Test converted from the Debug run, or a new Test created from scratch), it won't run the same way, i.e., it will fail, as it cannot find records related to the $Record that triggered the flow.
I've noticed that the Record ID is not the same between the Debug and the Test. In fact, the Record ID,
from test does not exists. I don't understand why running a Test is making up an inexistent record ID.
Please find below is the interview starting info with the correct (existing) Record Id for the Debug run.
Below is the interview starting info with the incorrect (non existing) Record Id for the Test run.
(actually, each time I run the Test, it makes up a new Record ID)
Has anyone already add this problem ? Is this a bug or is there something I'm missing? Is there a workaround?
Thanks in advance
#Flow #Record-Triggered #Record Id Value #UI Validation Tests #Test Case Management
Davis Johnson (SolomonEdwards) Forum Ambassador
Feb 26, 2024, 4:25 PM Flow tests take a copy of the triggering record as the record they operate on. And (similar to Apex tests), the record is never actually committed to the database, it exists solely as on-demand test data. Here is an article that sums up that functionality: https://help.salesforce.com/s/articleView?id=sf.flow_concepts_testing.htm&type=5
What exactly is the problem you are running into, though?
Hi Everyone,
I created a record trigger flow to do: when an agent link a contact to messaging session, that contact should be link to case as well
I have this following configuration for my flow
Start Record Trigger Flow
- Object: Messaging Session
- Configure Trigger: A record is updated
- Set Entry Conditions : EndUserContactId Is Null False
- When to Run the Flow for Updated Records : Only when a record is updated to meet the condition requirements
- Optimize the Flow for: Action and Related Record
Update Record
- How to Find Records to Update and Set Their Values: Update records related to the messaging session record that triggered the flow
- Set Field Values for the Case Records : ContactId-> $Record > Contact ID
Eric Burté (DEVOTEAM) Forum Ambassador
Nov 2, 2023, 9:34 AM Hello @Ariel Gencianeo what is the issue you have with your flow ? I do not see it in your flow description, but have you done a Get Records to retrieve the case(s) you want to update (one or many) ?
Eric
If any other GovCloud orgs are having this issue when using record-triggered Flows and the Approval Process, please report it here: https://issues.salesforce.com/issue/a028c00000yxXOv/approval-process-updates-in-final-step-with-also-updates-in-final-actions-will-trigger-flows-multiple-times
The Known Issue summary:
Flows triggered from Approval Process updates in final Approval Step, which also has field updates in Final Actions will incorrectly be triggered multiple times - despite Flow entry criteria to prevent this.
This only applies to field updates in a Final step, that are followed by updates in the Final Actions
I have a record-triggered flow on the Service Appointment object that runs when the status changes. When the status is updated to "Work Done" it triggers two subflows to run. How do I get the flow to roll back to the previous value if one of the subflow fails?
#Flow #Record-Triggered #Automation #Salesforce Field Service
Feb 13, 2024, 1:41 AM I've tried to replicate this and Salesforce automatically rollsback the record and throws a flow error.
Can you send a picture of your debug flow to see what's happening?
Hello Everyone,
I created a record trigger flow that when an agent link a contact to messaging session via Messaging Related Contact it should also link the contact into the case object, this flow is working when agent do the linking when messaging session is active but when status is ended it is not working, my question is why its not working?
Also below is my flow configuration:
Start record trigger flow:
- Select Object : Messaging Session
- Configure Trigger: A record is updated
- Set Entry Condition: None
- Optimize flow for: Action and Related Records
Decision:
- Outcome Order:
- Contact Not Found:
- Condition Requirements to Execute Outcome: Condition Requirements to Execute Outcome: All Conditions Are Meet (AND)
- Resource: {!$Record.MessagingEndUser.ContactId} Is Null True
- When to Execute Outcome: If the condition requirements are met
- Contact Not Found:
- Default Outcome: Contact Found
Update Records:
- How to Find Records to Update and Set Their Values: Specify conditions to identify records, and set fields individually
- Object : Case
- Condition Requirements to Execute Outcome: Condition Requirements to Execute Outcome: All Conditions Are Meet (AND)
- Id Equals {!$Record.CaseId}
- Set Field Values for the Case Records:
- ContactId <- {!$Record.MessagingEndUser.ContactId}
Nov 7, 2023, 10:06 AM Hi @Ariel Gencianeo, if you attempt to debug the flow adding a Messaging End User to a Messaging Session record with Status "Ended" , what flow elements are executed?
Im not sure if this is the group to ask this question in but is there any way to create records and update fields if a new record type is created on an object?
For example. The trigger would be: When a new record type (not a record) is created for the Account object, do the following:
- Update a picklist field on the User object
- Create a bell of toast notification on the Account
- Create a new account record with the record type that was created
- Associate that account record with a contact and a customer user
Unfortulatey flow triggers are record-specific. Is there a way to accomplish this without the use of apex?
Thanks!
-Nadira
Michael Brown (Salesforce) Forum Ambassador
Nov 6, 2023, 8:47 PM Hi Nadira,
There's actually a RecordType object a record is created against every time a record type is created. Unfortunately, this object is not available through record triggered flows. The only way I can think of doing this without custom code is to potentially use a Scheduled Flow. You can run a scheduled flow on the Record Type object, and potentially look for new record types that were created, but unfortunately this wouldn't perform actions in real time.
That said, can you elaborate on your use case as this scenario sounds very unique. Specifically, this part gives me some concern:
- Create a new account record with the record type that was created
It's recommended to have very few, or ideally no record types as much as possible, and creating an Account record each time a record type is added could really cause things to add up. Also, what is the intent for creating a record for each record type?
Thanks,
Mikey