• Kathleen Elisabeth Smith
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 3
    Replies
I'm currently having an issue with a trigger for a scheduled process on our Opportunity object. The trigger fires both before and after any updates to an opportunity, which causes a scheduled job to run and change the account type of the parent account 2 weeks later. 
Ex. I create opportunity on 8/5/21 with the status as "In-Progress" and nothing happens with the opp. This starts our opportunity trigger. On 8/19/21, two weeks later, the scheduled job runs, finds my opportunity that hasn't been modified since 8/5, and changes the account type. 
 
Recently, I noticed that merged accounts were triggering this process, as the opportunity in the accounts being re-parented count as updated, thus firing the Opportunity trigger on the day of the account merge. This is causing some accounts (leads or inactive clients) to revert to incorrect account types, which we need to avoid. 
 
I was thinking of creating a field that would be automatically updated each time an account is merged, which I can then use in the scheduler as an exclusion, however, I am having trouble executing this. Setting the field manually is a last case scenario, as we have different users merging accounts. Does anyone have any ideas on how I can create a field (checkbox/text/picklist/etc.) on the Account object that updates if merged with another account?
I have a trigger on the Opportunity object that runs after an opportunity is deleted, inserted, undeleted, or updated, or before one is deleted, inserted, or updated. We use this to start a process on the Status of an Opportunity/Contract.
  • If opportunity is "In Progress", then the account type is "Prospect"
    • 2 Weeks later, if this is still "In Progress", the account type is reverted to the previous account type (either "Lead' or "Inactive Client")
  • If opportunity is "Won", then the account type is "Active Client"
  • If opportunity is "Lost", then account type is either "Lead" or "Inactive Client"
Recently, while merging some accounts, I noticed that a couple of accounts that I had merged were reverting to their previous account type 2 weeks after the day that I had merged them. Since both accounts had opportunities merged into the master account and based on the time that the type was reverted, I was able to tell that the Opportunity_ContractTrigger was being set off when I was merging.

Has anyone had a similar issue to this when merging accounts, and what do you recommend I change in the Trigger so that it doesn't begin running when I merge accounts with opps?

Below is the code for trigger. Please let me know if you have any other questions. Thank you.

Opportunity_ContractTrigger
trigger Opportunity_ContractTrigger on Opportunity__c (after delete, after insert, after undelete, after update, before delete, before insert, before update) {

    if(trigger.isInsert && trigger.isBefore) {
      Opportunity_ContractTriggerHandler.OnBeforeInsert(trigger.new);
      
    } else if(trigger.isInsert && trigger.isAfter) {
        Opportunity_ContractTriggerHandler.OnAfterInsert(trigger.newMap);
        
    } else if(trigger.isUpdate && trigger.isBefore) {
        Opportunity_ContractTriggerHandler.OnBeforeUpdate(trigger.oldMap, trigger.newMap);
        
    } else if(trigger.isUpdate && trigger.isAfter) {
        Opportunity_ContractTriggerHandler.OnAfterUpdate(trigger.oldMap, trigger.newMap);
        
    } else if(trigger.isDelete && trigger.isBefore) {
        Opportunity_ContractTriggerHandler.OnBeforeDelete(trigger.oldMap);
        
    } else if(trigger.isDelete && trigger.isAfter) { 
        Opportunity_ContractTriggerHandler.OnAfterDelete(trigger.oldMap);

    } else if(trigger.isUnDelete) {
        Opportunity_ContractTriggerHandler.OnUndelete(trigger.new);
    }
}
I'm creating a record-triggered flow that is supposed to trigger every time an Account record is updated, when the checkbox field "Good to Clean" equals "True". From there, it is supposed to:
  • Get Records: gets tasks where the WhatID equals the Account ID
  • Loop: Loops through the record collection to delete each task record 
  • After Last Item it Gets Records: gets tasks where the WhoID equals the Contact ID
  • Loop: Loops through the record collection to delete each task record
  • After Last Item: it updates the "Good to Clean" field and sets to "False"
Below is an image of what the flow looks like currently. The loops are using the collection variables created by the Get Records). I added the loop in because I was getting the "Too many DML rows" error. The delete is set to run on the current item from the loop. 
User-added image

However, when I debug the flow, it gets stuck after the delete records. When I run the flow itself in my Sandbox, it only deletes 1 record that is unrelated to the account that triggered the flow. Below is a picture from the debug log. The account that triggered the flow only has 3 tasks on it, so it shouldn't be grabbing that many.
User-added image

Would someone be able to help me out and see where I'm running into the issue so that it doesn't grab the tasks related to the account that started the flow?
Hello, I am currently trying to create a flow that Gets Tasks whose Accounts are owned by certain users. Unfortunately, the Task OwnerID of the task is not the same as the Account Owner ID, which is what I need for my flow. I tried creating a custom field that would return this on the Activity Object, but the field doesn't show up (I think because it was a formula field). There is an Account lookup variable that shows, but I specifically need to grab the Account Owner ID, which I have not been able to do.

How can I add a field that will show up on the Flow Builder that I can use as a condition to make sure it is only grabbing tasks related to accounts owned by certain users?

Thank you!
Hello, I have a Scheduled Trigger on a custom object. I want the flow to only run on records that were created after yesterday's Date/Time. To do this, I created a Date/Time variable that grabs today's date, then I created a formula that takes the variable and subtracts 1, to make it yesterday. Then I go to the start object and put in the conditions "CreatedDate Greater Than or Equal (Yesterday's Date)". However, no matter what I put in for yesterday's date (my formula, date/time straight from the global flow value, etc.) it doesn't accept my field. It either gives me a "We don't recognize that value. Make sure it's a valid date/time value in this format: M/d/yyyy h:mm a" or error that says "The Start element can’t have a record filter condition that references a resource or element. Remove the condition that contains the unsupported value “$Flow.CurrentDateTime” or replace it with a literal value." How do I work around this so that I can get my flow to only run on records that were greated yesterday?

Thank you!
I have a trigger on the Opportunity object that runs after an opportunity is deleted, inserted, undeleted, or updated, or before one is deleted, inserted, or updated. We use this to start a process on the Status of an Opportunity/Contract.
  • If opportunity is "In Progress", then the account type is "Prospect"
    • 2 Weeks later, if this is still "In Progress", the account type is reverted to the previous account type (either "Lead' or "Inactive Client")
  • If opportunity is "Won", then the account type is "Active Client"
  • If opportunity is "Lost", then account type is either "Lead" or "Inactive Client"
Recently, while merging some accounts, I noticed that a couple of accounts that I had merged were reverting to their previous account type 2 weeks after the day that I had merged them. Since both accounts had opportunities merged into the master account and based on the time that the type was reverted, I was able to tell that the Opportunity_ContractTrigger was being set off when I was merging.

Has anyone had a similar issue to this when merging accounts, and what do you recommend I change in the Trigger so that it doesn't begin running when I merge accounts with opps?

Below is the code for trigger. Please let me know if you have any other questions. Thank you.

Opportunity_ContractTrigger
trigger Opportunity_ContractTrigger on Opportunity__c (after delete, after insert, after undelete, after update, before delete, before insert, before update) {

    if(trigger.isInsert && trigger.isBefore) {
      Opportunity_ContractTriggerHandler.OnBeforeInsert(trigger.new);
      
    } else if(trigger.isInsert && trigger.isAfter) {
        Opportunity_ContractTriggerHandler.OnAfterInsert(trigger.newMap);
        
    } else if(trigger.isUpdate && trigger.isBefore) {
        Opportunity_ContractTriggerHandler.OnBeforeUpdate(trigger.oldMap, trigger.newMap);
        
    } else if(trigger.isUpdate && trigger.isAfter) {
        Opportunity_ContractTriggerHandler.OnAfterUpdate(trigger.oldMap, trigger.newMap);
        
    } else if(trigger.isDelete && trigger.isBefore) {
        Opportunity_ContractTriggerHandler.OnBeforeDelete(trigger.oldMap);
        
    } else if(trigger.isDelete && trigger.isAfter) { 
        Opportunity_ContractTriggerHandler.OnAfterDelete(trigger.oldMap);

    } else if(trigger.isUnDelete) {
        Opportunity_ContractTriggerHandler.OnUndelete(trigger.new);
    }
}
I'm creating a record-triggered flow that is supposed to trigger every time an Account record is updated, when the checkbox field "Good to Clean" equals "True". From there, it is supposed to:
  • Get Records: gets tasks where the WhatID equals the Account ID
  • Loop: Loops through the record collection to delete each task record 
  • After Last Item it Gets Records: gets tasks where the WhoID equals the Contact ID
  • Loop: Loops through the record collection to delete each task record
  • After Last Item: it updates the "Good to Clean" field and sets to "False"
Below is an image of what the flow looks like currently. The loops are using the collection variables created by the Get Records). I added the loop in because I was getting the "Too many DML rows" error. The delete is set to run on the current item from the loop. 
User-added image

However, when I debug the flow, it gets stuck after the delete records. When I run the flow itself in my Sandbox, it only deletes 1 record that is unrelated to the account that triggered the flow. Below is a picture from the debug log. The account that triggered the flow only has 3 tasks on it, so it shouldn't be grabbing that many.
User-added image

Would someone be able to help me out and see where I'm running into the issue so that it doesn't grab the tasks related to the account that started the flow?
Hello, I have a Scheduled Trigger on a custom object. I want the flow to only run on records that were created after yesterday's Date/Time. To do this, I created a Date/Time variable that grabs today's date, then I created a formula that takes the variable and subtracts 1, to make it yesterday. Then I go to the start object and put in the conditions "CreatedDate Greater Than or Equal (Yesterday's Date)". However, no matter what I put in for yesterday's date (my formula, date/time straight from the global flow value, etc.) it doesn't accept my field. It either gives me a "We don't recognize that value. Make sure it's a valid date/time value in this format: M/d/yyyy h:mm a" or error that says "The Start element can’t have a record filter condition that references a resource or element. Remove the condition that contains the unsupported value “$Flow.CurrentDateTime” or replace it with a literal value." How do I work around this so that I can get my flow to only run on records that were greated yesterday?

Thank you!