230 likes | 349 Views
Sage CRM Developers Course. Workflow (2). Looking ahead to the classes. DP01: Introduction to the Development Partner Program DP02: Entities and the Data Model (Part 1 of 2) DP03: Entities and the Data Model (Part 2 of 2) DP04: Implementing Screen Based Rules (Part 1 of 2)
E N D
Sage CRM Developers Course Workflow (2)
Looking ahead to the classes • DP01: Introduction to the Development Partner Program • DP02: Entities and the Data Model (Part 1 of 2) • DP03: Entities and the Data Model (Part 2 of 2) • DP04: Implementing Screen Based Rules (Part 1 of 2) • DP05: Implementing Screen Based Rules (Part 2 of 2) • DP06: Screen and User Independent Business Rules • DP07: Workflow (Part 1 of 2) • DP08: Workflow (Part 2 of 2) • DP09: Using the API Objects in ASP Pages (Part 1 of 2) • DP10 : Using the API Objects in ASP Pages (Part 2 of 2) • DP11: Using the Component Manager • DP12: Programming for the Advanced Email Manager • DP13: Using the Web Services API • DP14: Using the Web Services API (Part 2 of 2) • DP15: Coding the Web Self Service COM API (Part 1 of 2) • DP16: Coding the Web Self Service COM API (Part 2 of 2) • DP17: Using the .NET API (Part 1 of 2) • DP18: Using the .NET API (Part 2 of 2)
Agenda • Workflow 2 • Escalations and Simple Notifications • Mechanisms Used • Escalation Service • Workflow Rules Table • Escalation Table • Building Escalation rules using views • Structure of an escalation rule • Controlling the firing point • Concept of Succession and Interactions with other rules • Limitations and available actions for escalation rules
Workflow • Control of process and data tasks • CRM offers graphical representation • Progress through logical arbitrary steps/states using ‘rules’ that govern transition • Rules • Time driven action • Uses SQL to check the data and time condition • E.g. whether the rule is executed • 2 types of rule • (Quick) Notification • Escalation rules
Workflow Configuration 1 • The Reminder field on the Enter New Task and Enter New Appointment pages is enabled. Setting this field to, for example, 10 minutes, displays a notification message on the user's screen 10 minutes prior to the planned time of the communication. • Quick Notifications are activated. • Escalation rules within Administration Timings Service Level Agreements are activated. • Escalation • This is the "Master Switch" that activates notification reminders and escalation rules. When this is set to Yes the follow behavior changes • All escalation-type rules within workflow are activated. • All escalation-type rules outside of workflow, including the default escalation rules supplied with the system are activated. • Notify Interval • The interval expressed in seconds between the server polling clients for notification reminders or escalation rules to be run if the CRM Escalation Service is not being used. If you are using the CRM Escalation Service, the minimum is 5 minutes by default. (300 second = 5 minutes)
Workflow Configuration 2 • Notification Display Count • The most commonly used type of workflow action associated with escalation rules is the "Notification", the on screen alert. This setting controls the number of notifications that can be shown on-screen at any one time. • Notify E-mail Name • If your Escalation rules or Quick Notifications are set to issue emails, then this field holds the name that appears on any e-mail sent by the rules. • Notify E-mail Address • The valid e-mail account that is used to send the e-mails. • Escalation Engine Tuned For • Selecting "Immediate Delivery" means that the notification gets processed when the Communication, or associated entity record, is created or edited, as well as every time the system polls at the Notification Interval.
Notifications & Escalations • Notifications are much easier for the System Administrator to define but are more limited in scope. • Both expressed using SQL • Both stored in workflow rules table • To list existing escalation rules from database use: • select * from workflowrules • where wkrl_ruletype = 'Time‘ • Both fired and controlled by the escalation mechanism • Both logged in escalations and SQL logs • Notifications tied to the use of the Escalations table • Table data used for basis of timings and SLA data.
Tracking Rule behaviour • Nov 19 2007 21:44:50.031 1160 2148 3 fselectsql,time,sql 31 select * from vWorkflowRulesTransitionInfo where ( WkRl_WorkflowId IS NULL OR (WkTr_TransitionId IS NOT NULL AND Work_Enabled = N'y')) AND WkRl_RuleType = N'Time' AND ((WkRl_NextRunTime < '20071119 21:44:50' OR WkRl_NextRunTime is NULL) OR WkRl_RunInterval IS NULL) AND WkRl_Enabled = N'Y' order by WkRl_Entity • Nov 19 2007 21:44:50.046 1160 2148 3 fselectsql,time,sql 0 select * from vWorkflowActions where COALESCE(WkRl_RuleId, 0) = 65 AND Wkac_action = N'Notify‘ • Nov 19 2007 21:44:50.046 1160 2148 3 fselectsql,time,sql 0 select * from vWorkflowActions where COALESCE(WkRl_RuleId, 0) = 117 AND Wkac_action = N'Notify‘ • Nov 19 2007 21:44:50.093 1160 2148 3 fselectsql,time,sql 32 select * from vEscalationComms WITH (NOLOCK) WHERE Escl_DateTime<'20071119 21:44:50' And Escl_UserID=1 AND Upper(RTRIM(comm_status))=N'PENDING' ORDER BY Comm_CommunicationId • Nov 19 2007 21:44:50.109 1160 2148 3 fselectsql,time,sql 15 select * from vWorkflowActions where COALESCE(WkRl_RuleId, 0) = 10127 AND Wkac_action = N'Notify‘ • Nov 19 2007 21:44:50.281 1160 2148 3 fselectsql,time,sql 172 select * from vNotificationOrders WITH (NOLOCK) WHERE orde_repricenotify = 'Y' and 1 = vNotificationOrders.orde_createdby AND ((Escl_EscalationId is NULL ) OR (Escl_WorkflowRuleId <> 10127 ) OR ((Escl_WorkFlowRuleId = 10127 ) AND Escl_Datetime < '20071119 21:44:50' AND Escl_UserId = 1)) ORDER BY Orde_OrderQuoteId • Nov 19 2007 21:44:50.296 1160 2148 3 fselectsql,time,sql 0 select * from vWorkflowActions where COALESCE(WkRl_RuleId, 0) = 10128 AND Wkac_action = N'Notify‘ • Nov 19 2007 21:44:50.421 1160 2148 3 fselectsql,time,sql 110 select * from vNotificationQuotes WITH (NOLOCK) WHERE quot_repricenotify = 'Y' and 1 = vNotificationQuotes.quot_createdby AND ((Escl_EscalationId is NULL ) OR (Escl_WorkflowRuleId <> 10128 ) OR ((Escl_WorkFlowRuleId = 10128 ) AND Escl_Datetime < '20071119 21:44:50' AND Escl_UserId = 1)) ORDER BY Quot_OrderQuoteId • Nov 19 2007 21:44:50.437 1160 2148 3 fselectsql,time,sql 0 select * from vWorkflowActions where COALESCE(WkRl_RuleId, 0) = 10123 AND Wkac_action = N'Notify‘ • Nov 19 2007 21:44:50.468 1160 2148 3 fselectsql,time,sql 16 select * from vEscalationQuotes WITH (NOLOCK) WHERE (quot_IsQuote is not null) AND UPPER(RTRIM(quot_Status))=UPPER(RTRIM(N'Active')) AND (Escl_DateTime<'20071119 21:44:50' And Escl_UserID=1) ORDER BY Quot_OrderQuoteId • Logs • SQL Log • Escalations Log • SysAdmin extension
Simple Notification Creation • Default Primary Entity Support • Cases • Communication • Company • Lead • Opportunity • Person • Rule based • e.g. send an e-mail to john when case = high priority and customer = xxxx • Email Notifications use templates and can have attachments
Building a Notification • Meta Data definition WorkflowRules Tables • Automatic Implicit use of Escalation rules When creating task with reminder Insert Communication Insert Communication Link Insert Escalation record • Rules based on views that link main entity with escalation table vNotificationCases vNotificationCommunication vNoticationCompany vNotificationLead vNotificationOpportunity vNotificationPerson
Example Escalation Rules • Escalation Rule • State to State in workflows • Time based (Escalation service) • Escalation Rule is set to trigger an action or series of actions based on an SQL WHERE clause. • (OrQu_ExpireDelivery<#T) AND (OrQu_IsQuote is not null) AND (UPPER(RTRIM(OrQu_Status))=UPPER(RTRIM(N'Active'))) • #Codes
Dates and Times in Escalation Rules • Example Trigger clause 1 (quot_IsQuote is not null) AND UPPER(RTRIM(quot_Status))=UPPER(RTRIM(N'Active')) AND (Escl_DateTime<#T And Escl_UserID=#U) #T and #U codes represent the current time and the currently logged on user. #T is equivalent to getDate in an implementation on SQL Server. (quot_IsQuote is not null) AND UPPER(RTRIM(quot_Status))=UPPER(RTRIM(N'Active')) AND (Escl_DateTime #T ) and ((oppo_targetclose - 28) < #T) • Example Trigger Clause 2 case_assigneduserid=#U and (case_notifytime+7)>#T • Or DATEDIFF (mi, case_notifytime, getdate()) > 30
Notification Actions • A rule will fire regularly according to the Notification interval. • When it fires it will refresh the Notification on the screen. • Column: • This is the datetime field that is referenced in the trigger clause of the rule. If it is left blank, then the notifications may not be dismissed. • When a notification is dismissed the column value in the database is set to null. When the snooze option is used the datetime is changed by the amount indicated. • Message: • Enter the "Name" of the message. This creates entry in the translation table, custom_captions. The capt_code is the name you have provided, the Capt_Family is ActionText and the Capt_FamilyType will be Tags. • To define the actual notification message that appears on the screen you have to edit the message once the action has been saved. • In escalation actions, you can use #[field name]# with any field from the current table or any field from the user table. • You can use HTML tags such as <BR> to force new lines. Or you can use tags such as <B> and <STRONG> • Table: • This is the table to be updated. The example rule under discussion "Quote Expiry" is based on the view vEscalationQuotes but you must name the Escalation table here.
Xxxx_notifytime • Tables such as Opportunity and Cases have a field called xxxx_notifytimee.goppo_notifytime. To create an escalation rule that uses this field then your SQL trigger clause should include the predicate • xxxx_notifytime < #T • Note: New for cases and opportunities the xxxx_notifytime will be blank unless you define the field in the Primary rule to set the xxxx_notifytime to a valid datetime. If the field is null it means that the notification will never fire.
The Escalation Table • The two of the default example rules, • Quote Expiry • Communication Reminder • are based on views that include the escalation table. • Quick Notification Rules are also based on views that link a main entity with escalation table • Case – vNotificationCases • Communication – vNotificationCommunication • Company – vNoticationCompany • Lead – vNotificationLead • Opportunity – vNotificationOpportunity • Person- vNotificationPerson • These types of rules are relying on some inbuilt behavior within CRM to populate the escalation table with the needed row. • For example there is automatic implicit use of Escalation rules when you create a task and set a reminder. • Not only is there a communication and a comm_link record created but there will also be an escalation record created.
The Stop Clause concept • The repeated firing of a rule is not an issue with on screen notifications but it would be an issue for a rule that repeatedly fired emails! • How do we stop an escalation rule from re-sending emails every 5 minutes? • The default escalation rule Email Reminder has the following SQL trigger clause • (CmLi_Comm_NotifyTime<#T) AND(UPPER(RTRIM(Comm_Status))=UPPER(RTRIM(N'Pending'))) AND (CmLi_SMSMessageSent ISNULL) AND (UPPER(RTRIM(Comm_SMSNotification))=UPPER(RTRIM(N'Y'))) • It has 2 actions. • The first is the sending of the email. • The second is an action to set a field value. • The field CmLi_SMSMessageSent is being used as the "Stop Clause". • The email message is only sent when the field is null and after the email is sent the field is set to "Y". • The action of firing the rule will create the condition that prevents it firing again.
The Interval • In the definition of an Escalation rule there is a field called "Interval". • This defines the interval, expressed in minutes, at which the rule will run. • If the Interval is set to 60 minutes, the escalation rule will run every hour. • SQL log extract • Nov 19 2007 21:44:50.031 1160 2148 3 fselectsql,time,sql 31 select * fromvWorkflowRulesTransitionInfo where ( WkRl_WorkflowId IS NULL OR(WkTr_TransitionId IS NOT NULL AND Work_Enabled = N'y')) AND WkRl_RuleType =N'Time' AND ((WkRl_NextRunTime < '20071119 21:44:50' OR WkRl_NextRunTimeis NULL) OR WkRl_RunInterval IS NULL) AND WkRl_Enabled =N'Y' order byWkRl_Entity • Escalation rules are checked for firing at the interval that is specified in the Workflow Configuration screen. (Default 300 seconds) • The system looks for all escalation and notification rules (WkRl_RuleType = N'Time') which are enabled (Work_Enabled = N'y')) and whether they are due to fire. • WkRl_NextRunTime < '20071119 21:44:50' OR WkRl_NextRunTime is NULL) ORWkRl_RunInterval IS NULL • Each escalation rule has a field called WkRl_NextRunTime. If the rule has an interval defined the WkRl_NextRunTime is updated with a new future due time based on the interval from the time it fires. • The Interval can be used to cause rules to fire repeatedly but within certain time frames. • For example, for high priority cases we could specify an email is to be sent between 7am and 9am every day to the assigned user reminding them of its importance.
Succession and Recursion • Succession • You can create a rule that when it fires will cause the conditions that will trigger another rule. • Proper succession will progress until data is stable. • Recursion • It is possible to create rules that trigger rules that trigger the original rules.
Looking ahead to the classes • DP01: Introduction to the Development Partner Program • DP02: Entities and the Data Model (Part 1 of 2) • DP03: Entities and the Data Model (Part 2 of 2) • DP04: Implementing Screen Based Rules (Part 1 of 2) • DP05: Implementing Screen Based Rules (Part 2 of 2) • DP06: Screen and User Independent Business Rules • DP07: Workflow (Part 1 of 2) • DP08: Workflow (Part 2 of 2) • DP09: Using the API Objects in ASP Pages (Part 1 of 2) • DP10 : Using the API Objects in ASP Pages (Part 2 of 2) • DP11: Using the Component Manager • DP12: Programming for the Advanced Email Manager • DP13: Using the Web Services API • DP14: Using the Web Services API (Part 2 of 2) • DP15: Coding the Web Self Service COM API (Part 1 of 2) • DP16: Coding the Web Self Service COM API (Part 2 of 2) • DP17: Using the .NET API (Part 1 of 2) • DP18: Using the .NET API (Part 2 of 2)