Hi,
I have a workflow that is checking a Date and when it is less then 30Days form now then send an Alert and set a Flag that the email has been sent so as to only send the email once.
So creating this via Worflow I do as follows
1: I updated all the ARD date fields to NULL
2: I then via the CRM edited one of the Accounts and set the ARD Date to tomorrow.
3:Created a custom checkbox to use as a flag.
3: Configured the Workflow as follows.
1:After Time Elapses
2: New and Existing Records
Conditions:
1: When ARD is less then 30 Days from now
2: When fdc_1month_ard_alert_c equals NO
Alerts
1: Custom Email alert - to the assigned User
Actions
1: Set the checkbox flag as Yes
For the purpose of testing I have set all the dates to (NULL) in my Database and reset all the flags. I then edited 1 Account and set the date field I am checking to tomorrow. Then I activate the Workflow. I get the 1 Email relating to the Account I edited and only the One - THIS IS CORRECT...
But I also get 100s of other duplicate emails relating to other Accounts. So I get the emai ltwice (Should only be One) the date that is set in the CRM according to teh Alert that includes the date field is 200-01-01. I then check the CRM and I have only the one date edited to tomorrow in one account and I check the DB also and again there is no date of 200-01-01.
Anyone know what is happening, This is the workflow.php that is created,
RgdsPHP Code:<?php
include_once("include/workflow/alert_utils.php");
include_once("include/workflow/action_utils.php");
include_once("include/workflow/time_utils.php");
include_once("include/workflow/trigger_utils.php");
//BEGIN WFLOW PLUGINS
include_once("include/workflow/custom_utils.php");
//END WFLOW PLUGINS
class Accounts_workflow {
function process_wflow_triggers(& $focus){
include("custom/modules/Accounts/workflow/triggers_array.php");
include("custom/modules/Accounts/workflow/alerts_array.php");
include("custom/modules/Accounts/workflow/actions_array.php");
include("custom/modules/Accounts/workflow/plugins_array.php");
if( ( (
(
isset($focus->pr_annual_return_date_c) && $focus->pr_annual_return_date_c !='' && isset($focus->pr_annual_return_date_c) && $focus->pr_annual_return_date_c !='0000-00-00'
&& $focus->fetched_row['pr_annual_return_date_c']!= isset($focus->pr_annual_return_date_c) && $focus->pr_annual_return_date_c
)
) ) || ( (
(
isset($focus->pr_annual_return_date_c) && $focus->pr_annual_return_date_c !='' && isset($focus->pr_annual_return_date_c) && $focus->pr_annual_return_date_c !='0000-00-00' )
) && !empty($_SESSION['workflow_cron']) && $_SESSION['workflow_cron']=="Yes" ) ){
//Frame Secondary
$secondary_array = array();
//Secondary Triggers
//Secondary Trigger number #1
if( (
(
isset($focus->fdc_1month_ard_alert_c) && $focus->fdc_1month_ard_alert_c == 'false'||
isset($focus->fdc_1month_ard_alert_c) && $focus->fdc_1month_ard_alert_c == 'off'||
isset($focus->fdc_1month_ard_alert_c) && $focus->fdc_1month_ard_alert_c == '0'
)
) ){
$trigger_time_count = '0';
$time_array['time_int'] = '-2592000';
$time_array['time_int_type'] = 'datetime';
$time_array['target_field'] = 'pr_annual_return_date_c';
$workflow_id = '671571c7-c0e2-4dd7-02e5-4b5589effce7';
if(!empty($_SESSION["workflow_cron"]) && $_SESSION["workflow_cron"]=="Yes" &&
!empty($_SESSION["workflow_id_cron"]) && $_SESSION["workflow_id_cron"]==$workflow_id){
global $triggeredWorkflows;
if (!isset($triggeredWorkflows['a3bacd8b_8ed9_af41_84e7_4b5599bc7091'])){
$triggeredWorkflows['a3bacd8b_8ed9_af41_84e7_4b5599bc7091'] = true;
$alertshell_array = array();
$alertshell_array['alert_msg'] = "7b3007b3-ed77-8a53-8840-4b4f1075c3c5";
$alertshell_array['source_type'] = "Custom Template";
$alertshell_array['alert_type'] = "Email";
process_workflow_alerts($focus, $alert_meta_array['Accounts0_alert0'], $alertshell_array, false);
unset($alertshell_array);
process_workflow_actions($focus, $action_meta_array['Accounts0_action0']);
process_workflow_actions($focus, $action_meta_array['Accounts0_action1']);
}
}
else{
check_for_schedule($focus, $workflow_id, $time_array);
}
//End Frame Secondary
// End Secondary Trigger number #1
}
unset($secondary_array);
//End if trigger is true
}
//end function process_wflow_triggers
}
//end class
}
?>
Chris


LinkBack URL
About LinkBacks




Reply With Quote
Bookmarks