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
indranily81indranily81 

workflow rule needs to be fired on no database modification

hi,

 

I have a worflow rule to be fired if there is no lead record created within every 1 hour.Mail will be sent to

the logged in user if no lead record is inserted in every 1 hour.I am stuck with the idea of trapping an event

when there is no database updation. Any idea will be of great help.

Best Answer chosen by Admin (Salesforce Developers) 
indranily81indranily81

Hi,

 

At last the problem is solved by using 1 workflow and two triggers. The system now sends mail every 1 hour. 

its a combination between insert and update trigger and the workflow.

 

 

Cheers

All Answers

Rajesh ShahRajesh Shah

I am not sure if the following approach will work or not bu give it a try:

 

1. Create a custom Object with just 1 field of type Checkbox and a datetime field. Only 1 record is created of this object and the checkbox is initially unchecked and datetime field null.

 

2. Create a time based workflow which says that everytime the checkbox was checked, send an email alert after 1 hour of the datetime field.

 

3. Every time a lead is created, check this checkbox using Insert Trigger and update the datetime field = CreatedDate.

 

4. I assume that since it is a time based workflow, the timing of the workflow will be updated everytime the datetime field will be updated. So if records keep getting created, the time based trigger will keep on getting delayed in firing. But when no record is created for an hour, it will fire.

 

Let me know if this works. 

Message Edited by Rajesh Shah on 10-28-2009 09:10 PM
indranily81indranily81

Hi rajesh,

 

I tried as per steps mentioned. But no mail is generated. I tried for the whole day but seems somwhow the workflow rule is not firing. Any advice would be of great help.

Rajesh ShahRajesh Shah

What is your workflow condition?

 I would keep it as Everytime a record is created or updated and did not previously meet the criteria and condition as Checkbox checked.

indranily81indranily81

Hi,

 

Sorry for being not informative. Actually I didn't receive the mail on my corporate mail ID. the reason might be some network issue/firewall. but changing that to gmail ID worked.

 

But the solution couldn't met my requirement as I needed to generate the mail every 1 hour if no lead is inserted in that 1 hour. I have got the mail only for the first time. I am working on it though and any idea would be of great help.

 

 

 

indranily81indranily81
Is there any out of the box functionality in SF to fire a workflow rule in repititive manner ?
Rajesh ShahRajesh Shah

I dont think there is any out of the box functionality available for that.

Maybe you can have another time based field update which is such that it again fires the workflow and also updates the DateTime field by adding an hour to it. 

 

indranily81indranily81

I thought about this option too. But since I need to trigger the mail every 1 hour, I need to add 24 such fields to fire the workflow evry hour. I think that is not a very good design...And think about the load on the application if I need to activate this rule for next 1 year.

 

 

 

Rajesh ShahRajesh Shah

I dont understand why 24 fields are required. What I meant was this.

1. The system will have only 1 workflow.

2. The workflow will be fired in the following conditions: 1 which is already working and the other when actually the time based action of this workflow takes place. So basically the workflow will activate itself again with the time again advanced by an hour.

 

If we are able to build the workflow with such a condition, then it will work perfectly. 

indranily81indranily81

I am trying to build this workflow. I will update if i am successful.

Thanks again for the help. Any idea are most welcome.

indranily81indranily81

Hi,

 

At last the problem is solved by using 1 workflow and two triggers. The system now sends mail every 1 hour. 

its a combination between insert and update trigger and the workflow.

 

 

Cheers

This was selected as the best answer
Rajesh ShahRajesh Shah

Glad that you were able to develop it.  :smileyhappy:  Could you share your logic so that we get an idea how exactly you solved it?

 

Thanks,

Rajesh

indranily81indranily81

Sure,

The steps are:

 

1. Build a custom object having two boolean fields.

 

2.  write a insert trigger on the object on which you intend to fire the workflow. Say if you want to receive a mail every 1 hour when no lead is created. Then write a insert trigger on lead.

 

3. this insert trigger will insert a new record for the custom object and will make first checkbox true.

 

4. write a workflow depending on the status of that checkbox which is now true for the insert trigger.  this workflow will send mail after 1 hour and will check the second checkbox and uncheck the first one.

 

 

5. write an update trigger on the custom object. The logic is if the second check box is true then delete the old record and insert a new record with first checkbox true.

 

6. this goes on as a loop and you will see the mails.