Friday, April 29, 2011

Create a new algorithm type that creates a case for a person from within a case

Introduction 
This is a common requirement for many clients. Ex. a utilities company has two case types:
1-Site inspection for new meter installation
2-Meter installation
When the first case is completed, and at a step "Initialize Meter Installation" the second case should be created automatically.

In this example, I will demonstrate using CC&B config tools, namely Creating Business Objects, Business Services, Algorithm types based on Plug-in script, and scripts. So to fully understand this example, you need basic understanding of these CC&B config tool in addition to XML, XPATH, and service oriented architecture.

This example is for CC&B version 2.1, anyhow it works fine on CC&B version 2.3
Steps are summarized as follows:

  1. Create a Business Object (BO) to retrieve case information that will passed to the new case that will be created (Ex. person ID, Premise ID, Account ID...).
  2. Create Business Service (BS) to initialize the new case.
  3. Create a script that will invoke the BO and pass the data to the BS.
  4. Create an algorithm type that can be plugged into "Case Type - Enter Status". This Algorithm Type has one parameter which is Case Type Code of the new case to be created. this makes it generic and re-usable.
  5. Create an algorithm that can be plugged into a case.

Detailed Steps

1-In BO screen (Business Object +), Enter the following data:
Code : CM_BO_CASE
Description : Case business object
Detailed Description : Case business object ... write a comprehensive one !
Maintenance Object : CASE
Schema
<schema> 
    <CaseID mapField="CASE_ID"/>  
    <CaseTypeCD mapField="CASE_TYPE_CD"/>  
    <CaseStatusCD mapField="CASE_STATUS_CD"/>  
    <AccountID mapField="ACCT_ID"/>  
    <PremiseID mapField="PREM_ID"/>  
    <PerID mapField="PER_ID"/>  
    <UserID mapField="USER_ID"/>  
    <ContactPerID mapField="CONTACT_PER_ID"/>  
    <ContactMethod mapField="CONTACT_METH_FLG"/>  
    <ContactInstr mapField="CONTACT_INSTR"/>  
    <PhoneTypeCd mapField="PHONE_TYPE_CD"/>  
    <Phone mapField="PHONE"/>  
    <Extension mapField="EXTENSION"/>  
</schema>

2-In BS screen (Business Service +), enter the following data:
Business Service: CM_CASE_BS
Description: Case Business Service
Detailed Description: Case Business Service... write a comprehensive one !
Service Name: CILQCASP
Schema : 

<schema pageAction="add"> 
    <CaseID mapField="CASE_ID"/>  
    <CaseTypeCD mapField="CASE_TYPE_CD"/>  
    <CaseStatusCD mapField="CASE_STATUS_CD"/>  
    <AccountID mapField="ACCT_ID"/>  
    <PremiseID mapField="PREM_ID"/>  
    <PerID mapField="PER_ID"/>  
    <UserID mapField="USER_ID"/>  
    <ContactPerID mapField="CONTACT_PER_ID"/>  
    <ContactMethod mapField="CONTACT_METH_FLG"/>  
    <ContactInstr mapField="CONTACT_INSTR"/>  
    <PhoneTypeCd mapField="PHONE_TYPE_CD"/>  
    <Phone mapField="PHONE"/>  
    <Extension mapField="EXTENSION"/>  
</schema>

3-In script screen (Script +), enter the following data:
Script Tab page:
Script: CM-CR-CASE
Description: Create Case for the person in a Case during enter case status
Script type: Plugin Script
Algorithm Entity: Case Type-Enter Status

Data Area tab page:
Schema type: Business Object, Object : CM_BO_CASE, Data Area Name: CM_BO_CASE
Schema type: Business Service, Object : CM_CASE_BS, Data Area Name: CM_CASE_BS
Steps tab page:
Its up the to user to decide wither to use one "Edit Data"  step and put all the logic into it, or it can be divided into several steps to make it more understandable and maintainable. 
I chose to make 5 nice and readable steps:

Step sequence :10
Step Type : Move Data
Text : Move data from Current Case ID to Case BO to retrieve other required data
Source field Type: Data Area
Source Field Name: parm/hard/case/id
Destination Field Type: Data Area
Destination Field Name: CM_BO_CASE/CaseID

Step sequence:20
Step type : Invoke business object
Text: Invoke Case Business Object to get the missing data like PER_ID, ACC_ID, PHONE.....
Group Name: CM_BO_CASE
Business Object: CM_BO_CASE
Action: Read

Step sequence: 30
Step Type: Edit Data
Text: Move (copy) data obtained from the BO into Business Service to prepare for the case creation
Edit Data Text (note here that the first move statement gets the value from algorithm first parameters): 

move "parm/soft[1]/value" to "CM_CASE_BS/CaseTypeCD";
move "CM_BO_CASE/AccountID" to "CM_CASE_BS/AccountID";
move "CM_BO_CASE/PremiseID" to "CM_CASE_BS/PremiseID";
move "CM_BO_CASE/PerID" to "CM_CASE_BS/PerID";
move "CM_BO_CASE/UserID" to "CM_CASE_BS/UserID";
move "CM_BO_CASE/ContactPerID" to "CM_CASE_BS/ContactPerID";
move "CM_BO_CASE/ContactMethod" to "CM_CASE_BS/ContactMethod";
move "CM_BO_CASE/ContactInstr" to "CM_CASE_BS/ContactInstr";
move "CM_BO_CASE/PhoneTypeCd" to "CM_CASE_BS/PhoneTypeCd";
move "CM_BO_CASE/Phone" to "CM_CASE_BS/Phone";
move "CM_BO_CASE/Extension" to "CM_CASE_BS/Extension";

Step sequence: 40
Step type: Invoke business service
Text: Invoke Business Service to create the case
Group Name: CM_CASE_BS
Business service: CM_CASE_BS

Step sequence: 50
Step type: Terminate 
Text : Normal Termination
Error : No Error


4-In Algorithm Type screen (Algorithm Type +)
Algorithm type: CM_CRE_CASE
Description : Create Case for person during Enter Status
Detailed description : Create Case for person during Enter Status (make it comprehensive )
Algorithm Entity: Case type-enter status
Program type: Plug-in script
Plug-in script: CM-CR-CASE
Parameters : 
Sequence : 10, Parameter: Case Type CD, Required? "Y"

Now you are good to create a new algorithm, specify the case type code to be created, and plug
 into a case enter status !

Enjoy








DISCLAIMER:  This information is provided "as is". The author of this information disclaim any loss or liability, 
either directly or indirectly as a consequence of applying the information presented herein, or in regard to the use
 and application of said information. No guarantee is given, either expressed or implied, in regard to the
 merchantability, accuracy, or acceptability of the information

No comments:

Post a Comment