function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
R_ShriR_Shri 

Time Dependent Trigger Issue

I have a scenario wherein :

               1. If any field gets updated in Opportunity (master) a workflow (outbound message) has to be fired from custom_object__c (detail). This custom_object__c has some formula fields which takes value from Opportunity and some other fields. So with the help of this workflow I send(to another system) all fields of custom_object__c via outbound message.

    For this I have created:

                     A. a custom_field__c (of dataType checkbox) in custom_object__c,

                     B. a trigger (it has a functionality that if any field gets updated in Opportunity the value of custom_field__c  becomes true ). 

  trigger tgrAfterUpdateOpportunity on Opportunity (After update) {

  }

                    C. And on the basis of status of custom_field__c (if true)  a workflow is fired and hence the outbound message. 

 

                2. Now the problem arises is that once the value of custom_field__c  becomes true my workflow becomes useless as it is not sending the new updated values of opportunity (it sending the same values as when the custom_object__c becomes true for the first time)

          

              For this I have created a time dependent workflow which toggles the value of custom_field__c  after defined time, and hence my functionality again starts working fine.

 

          But the main issue is Time-Dependent Workflow Actions has minimum time limit of 1 hour . So is there any method by which I can set a  Time-Dependent Workflow's limit to few seconds or a sew minute at max? (so that my functionality keeps on working fine continuously.) or else please suggest some idea wherein the value of custom_field__c gets toggled after the outbound message (of first workflow ) has been fired.

 

Any help would be highly appriciated.

 

Thanks

R_Shri

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox
Just use a Field Update on the workflow rule that kicks off the outbound message. Workflow rules evaluate all of their conditions, then execute all of their actions, then repeat the process if the "re-evaluate rules" checkbox is checked for that action. In other words, the workflow rule "appears" to execute in parallel, meaning that the same rule can both uncheck the box and send the outbound message.

Alternatively, you could also just use a @future method to uncheck the box. The time it takes for the asynchronous code takes to execute is usually within a few seconds, but guaranteed to occur after the transaction completes. It would also be similarly possible to use the new System.scheduleBatch function to kick off a batch class that executes after the transaction completes about a minute later, or you can also just System.executeBatch, which also won't execute until the current transaction completes.

You could also have the outbound message handler (the server that processes the outbound messaging) to update the checkbox for you using the API.

All Answers

sfdcfoxsfdcfox
Just use a Field Update on the workflow rule that kicks off the outbound message. Workflow rules evaluate all of their conditions, then execute all of their actions, then repeat the process if the "re-evaluate rules" checkbox is checked for that action. In other words, the workflow rule "appears" to execute in parallel, meaning that the same rule can both uncheck the box and send the outbound message.

Alternatively, you could also just use a @future method to uncheck the box. The time it takes for the asynchronous code takes to execute is usually within a few seconds, but guaranteed to occur after the transaction completes. It would also be similarly possible to use the new System.scheduleBatch function to kick off a batch class that executes after the transaction completes about a minute later, or you can also just System.executeBatch, which also won't execute until the current transaction completes.

You could also have the outbound message handler (the server that processes the outbound messaging) to update the checkbox for you using the API.
This was selected as the best answer
R_ShriR_Shri

Hi sfdcfox

sfdcfoxsfdcfox
From the design of the application, I don't believe you'll be able to get away with a click-only configuration-- some trigger code would be necessary. This is mostly because workflow rules don't work well across objects.