Monday, April 25, 2011

Deploy Integration Object to runtime DB

This Functionality has been introduced in Siebel 8.1

Pre Siebel 8.1 the only way to solve this problem was to have SRF Change. In Siebel 8.1 world here is what we can do to avoid SRF change
  1. Opened Siebel Tools by connecting to Production Repository.
  2. Made the change to the Integration Object
  3. Right Click and Deploy to runtime
If you are still getting the same error as that of before i.e prior modification of IO then issue could be of clear the cache and the only way to do it is have a server restart.

Follow these steps after deploying the IO:
  1. Go To Administration – Web Service (either Inbound or Outbound)
  2. Click on Clear Cache button
  3. You are done
Yes, it is as simple as that. I did notice one thing that if you EAI Object manager is not used heavily than you might not require this.

Thursday, April 14, 2011

How to Read SOAP Response In siebel

function ReadResponse(psInput,psOutput)


{

//******************************************************

// Description: The purpose of this function is to read the



incoming response XML from middleware and check for success/error.



//**********************************************************

var psParent;

var psChild;

//var psInCopy = TheApplication().NewPropertySet();





try {

var isSuccess =

true;

psParent = TheApplication ().NewPropertySet ();

psParent = psInput;

var iChildCount = psParent.GetChildCount();



psChild =

TheApplication ().NewPropertySet ();

//var strLevelType = psParent.GetType();

//var strLevel ="";

var isTraversing = true;

var iChild = 0

var

strResponseType;

var strErrorCode = "";

var strErrorMessage = "";

var strErrorSeverity = "";

var blnIsErrorDetail = false;

while ((isTraversing)

&& (iChildCount > 0) && (iChild < iChildCount)) {

psChild = psParent.GetChild(iChild);

iChild++;

//strLevelType

= psChild.GetType();

// *** UNCOMMENT TO TRACE *********

// TheApplication().Trace("(" + iChild + "/" + + iChildCount + ") " + strLevelType);

//*******************************************************



// check for parent tags to force drill down to specific child tags

// if

(psChild.GetType() == "CustomerInfoAccessResponse") {

if ((psChild.GetType() == "CustomerInfoAccessResponse")

(psChild.GetType() == "PayLoad")



(psChild.GetType() == "Operation")

(psChild.GetType() == "Output")

((psChild.GetType() == "ErrorMessage") && (blnIsErrorDetail))) {

if

(psChild.GetType() == "Output") {

blnIsErrorDetail = true;

}

psParent = psChild;



iChildCount = psParent.GetChildCount();

iChild = 0;

// check for tags to get values

} else if

(psChild.GetType() == "ResponseType") {

strResponseType = psChild.GetValue();

if (strResponseType != "ACK") {



isSuccess = false;

}

} else if (psChild.GetType() == "ErrorMessage") {

// this tag is used 2

ways - as parent and child-value - ignore error

try {

strErrorMessage = strErrorMessage + psChild.GetValue();



} catch(e) {}

} else if (psChild.GetType() == "ErrorCode") {

strErrorCode = psChild.GetValue();

} else

if (psChild.GetType() == "ErrorDetailMessage") {

strErrorMessage = strErrorMessage + "; Detail: " + psChild.GetValue();

} else

if (psChild.GetType() == "ErrorSeverity") {

strErrorSeverity = psChild.GetValue();

}

}





psOutput.SetProperty("WMService","getOpportunityByReservation");

if (isSuccess) {

psOutput.SetProperty("Error Message",strErrorMessage);



psOutput.SetProperty("Response","Success");

psOutput.SetProperty("ErrorCode","None");

psOutput.SetProperty("ErrorApp","None");



psOutput.SetProperty("DisplayMsgCode","ACK");



// KCS -08/28/06-added code here to parse inputs and update the outputs

//

either removing the Status property or changing the value of the

// status property.

} else {

psOutput.SetProperty("Error

Message",strErrorMessage);

psOutput.SetProperty("Response","Error");

psOutput.SetProperty("ErrorCode",strErrorCode);



psOutput.SetProperty("ErrorApp",strErrorSeverity);

//psOutput.SetProperty("DisplayMsgCode",strResponseType);



psOutput.SetProperty("DisplayMsgCode","Dta01");

}



} catch(e) {

throw(e);

} finally {

psParent = null;

psChild = null;

}

}



How to create a VBC without Script - XML Gateway

Key Points:


• Using XML Gateway Business Service to serve the VBC

• Using Business Integration Manager (Server Request) as Transport Protocol

• Create your own workflow to deal with the logic


Architecture:


• VBC trigger XML Gateway: Init(), Query(), etc

XML Gateway generates xml files corresponding to the command. Eg. It generates xml file







Contact







Matching Init() command

• XML Gateway triggers Business Integration Manager to invoke SendReceive() method



• Business Integration Manager sends the xml files generated by XML Gateway to Workflow



• Workflow gets the xml file and passes it to external application like MQ Series, MSMQ, HTTP Web Application or processes it inside the Siebel



• Workflow gets the result xml file from external application or Siebel Application and passes it back to Business Integration Manager (BIM)



• BIM receives the result xml file and passes back to XML Gateway to populate the VBC







Points of configuration:



• Create a BC of Class CSSBCVExtern



• Configure the above BC with following user properties

Service Name: XML Gateway

Service Parameters: Transport=EAI Business Integration Manager (Server

Request);ProcessName=;



• Create a process property as type of binary/string. Set the default to . It will hold the xml file generated by XML Gateway



• Create a process property as type of binary and named . It will pass back to BIM and XML Gateway to populate the VBC



• Analyse the xml file generated by XML Gateway to determine what action to be taken. (Query, Insert…)



• Use XSLT to transform the result xml file to the format XML Gateway needs to populate the VBC




Sample Workflow Design





Workflow Process Properties





Step Type Method Business Service

SaveIncomingXML Business Service Send EAI File Transport

Input Argument Type Value Property name

Process Property IncomingXML

FileName Literal C:\XMLGateway.txt

AppendToFile Literal True











Step Type Method Business Service

Analyse Incoming XML Business Service Echo Workflow Utilities

Output Argument Type Value Property name

CheckPoint Expression InStr([&IncomingXML],"fields-req")













Step Type Method Business Service

Is Init Request? Decision Point

Branch Condition Expression

Is Init Condition (CheckPoint Greater Than('0'))

Not Init Default







Step Type Method Business Service

Get Init XML Response Business Service Receive EAI File Transport

Input Argument Type Value Property name

FileName Literal C:\TEMP\TestVBCInit.xml

Output Argument Type Value Argument name

Output Argument











Step Type Method Business Service

Analyse Incoming Query XML Business Service Echo Workflow Utilities

Output Argument Type Value Property name

CheckPoint Expression InStr([&IncomingXML], "query-req")













Step Type Method Business Service

Is Query Request? Decision Point

Branch Condition Expression

Is Query Condition (CheckPoint Greater Than('0'))

Not Query Default







Step Type Method Business Service

Get Query XML Response Business Service Receive EAI File Transport

Input Argument Type Value Property name

FileName Literal C:\TEMP\TestVBCQuery.xml

Output Argument Type Value Argument name

Output Argument





TestVBCQuery.xml











Mr.

Sara

Chan







TestVBCInit.xml





















Monday, March 28, 2011

I want to touch Sachin's feet: Gavaskar

New Delhi: Sunil Gavaskar, bowing down to the remarkable double century smashed by Sachin Tendulkar on Tuesday, said he would like to touch the 36-year-old's feet.
Tendulkar cracked an unbeaten 200 against South Africa in Gwalior to become the first batsman in ODIs to hit a double hundred.
"Who else has 93 international hundreds, who else has more than 14,000 ODI runs, who else has more than 17, 000 Test runs? Nobody. I would really like to bend down and touch his feet. If somebody is at that pedestal, I would like to do that," Gavaskar told CNN-IBN.
Gavaskar, who has been Tendulkar's idol ever since he started playing cricket, was missing from the commentary box in Gwalior.
"I am completely overwhelmed. I wish I was there to congratulate him and tell him to carry on to reach more peaks," said an emotional sounding Gavaskar.
Gavaskar saluted Tendulkar's invincible spirit and hinted that the master blaster has a long way to go.
"What drives him on is the little boy in him. And that little boy in him just wants to play, play and play. That is the spirit that keeps him going. And then of course there is the incentive of representing your country," remarked Gavaskar.
"The best part about Sachin Tendulkar is that he just focuses on the present. He doesn't think about the past," he added

Sending Email from Siebel Application

1.To send mails from Siebel
Following steps need to be done:
1.To create Communication Driver Profile parameters.
2. Based on Communication Profile, Siebel send / receive mails via mail server.


To create Communication profiles follow the Steps mentioned in approach.
1.To Create Driver Parameters & Profile (For Dev Server)
a)Go to Sitemap->Admin – Communications -> Communications Drivers and Profiles
b) Query “Internet SMTP/POP3 Server” and select profile view. Create new profile in profile applet (ex. ONE Customer Relations)
c) Next, create the following records for Profile Parameter Overrides.
From Address abc@xyz.com (email id of account from which to send mail)
LogDebug TRUE
POP3 Account Name qwq@ab.com (email id in which mail should come)
POP3 Account Password 12345de (Password of the account in which to send)
POP3 Server 111.100.11.123("external client where u check email)
POP3 Server Port 111( for email server)
PollingInterval 11( for email server)
SMTP Server 111.100.11.123
Siebel Server sib_dev
( for these ip confi you have to check with mail server team)
To trigger the mail you need to configure workflow with following steps:
Steps of creating Siebel Workflow

1.Copy the siebel Vanilla Workflow that is with name “Siebel Message send email for activity owner” & name copy version as “New Mail”.
2.In workflow Process properties don’t change anything.
Project – Service , Mode-> Service Flow , BO – Service Request
3.In Workflow step select the business Service method as Send Message.
4.Right click the WF Process select edit workflow process, the select send Email right click select Input parameters, do the following changes in Input parameters:
Name Value
i) CommProfile ABC New
ii) MsgBody Notification: this product is going to finished
iii) MsgSubject Product Notification
iv) MsgToList qwq@ab.com
v) ProcessMode Remote
5 you can check your Ssiebel server name by going thorugh :
"Siebel Server" "abc_Sieb_server"(you can get from Administration – Serever manngement - > Server & you can get sibel server name).
6. Make sure outbound communication Manager should be in Active mode.
7. Validate the workflow; if no error then Simulate works flow. Done!!!!!!!!!!
8. If Simulation is being successful.
The Deploy your workflow by Selecting WF in tools & clicking Deploy tab at top right
9. Go to Siebel Application – Admin – Business process- Workflow Process –Query for your WF. Click activates.
If it is activated it will get populated in bottom applet.

VBC in Siebel

Virtual Business Component:
Virtual business components (VBCs) are mechanisms in Siebel EAI by which data from an external system can be viewed in Siebel applications without having to replicate that data within the Siebel Database. We will discuss VBC in a series of 4 articles. Here is the first one, which will help you in understanding why we require VBC and what are VBC’s?.


Business Requirement [Data Sharing Problem]
Following are the common cases where we need to pull data from external database using VBC
1. Users want to access data anywhere in the enterprise
2. Users want to use the same user interface to access any data
3. Users want to display and manipulate external data from within a Siebel application without storing it in the Siebel database


Virtual Business Component Solution
1. Uses a class of business component based on data stored outside of the Siebel database
2. Is defined and behaves like a regular business component
3. Displays data from a external application in a Siebel applet
4. Does not store the external data in the Siebel database
Mapping Virtual Business Components
1. An applet maps to a VBC and is included in a business object (View) just like a regular business component
2. A business object can contain regular business components and virtual business components

VBCs Rely on Business Service and Scripting
A regular Siebel business component uses a C++ Class
(such as CSSBusComp) to manipulate data in the Siebel database
1. Query for records
2. Modify records
3. Create records
4. Delete records
A virtual business component requires a business service with a script to manipulate data in an external application
1. Query for records
2. Modify records
3. Create records
4. Delete records
Data Manipulation Methods
A VBC requires a business service to provide the following standard methods for manipulating external data
1. Init (required)
2. Query (required)
3. Preinsert (optional)
4. Insert (optional)
5. Update (optional)
6. Delete (optional)
The VBC business service may also map Siebel data to external data

VBCs and EAI Transports
VBCs require an EAI transport to send and receive data
Available transports and interfaces for a VBC include:
1. EAI MQSeries Server Transport
2. EAI MQSeries Application Messaging Interface (AMI)Transport
3. EAI MSMQ Transport
4. EAI File Transport
5. EAI HTTP Transport
6. Microsoft BizTalk 2000


Two Ways to Implement a VBC
Create a custom business service with the necessary scripting
1. Siebel eScript, or
2. Siebel Visual Basic
Use the Siebel XML Gateway Business Service, which comes with the required methods for data access and manipulation
When a Virtual Business Component is Appropriate?
When the external system is the system of record
There is no need to duplicate the external data in the Siebel database
When the data from the external system is not defined within the Siebel schema
When the Siebel application is just one of many applications
Limitations of Virtual Business Components
1.VBCs can only be a child components, never parents
Example: A VBC can provide account detail from an external application only if the Siebel application has the parent account record
2.VBCs do not support many-to-many relationships or joins
3.VBCs cannot be specialized business components
Example: Quotes and Forecasts cannot be implemented as VBCs
4.VBCs cannot contain multi-value groups (MVGs), nor can they be the business components for MVGs
5.VBCs do not support drilldowns and sort capabilities
Both use a named search, which is not possible in a VBC
6.VBC field names must map to field names in the external system
7.VBC detail data cannot appear in a wireless view
A wireless view displays only one (master) applet; a VBC must be a child
8.Mobile users cannot use VBCs
Remote data is not stored in the Siebel database
There is no logging support


This post show how to configure a VBC for invoke an EAI WF with a minumun amount of scripting in siebel:
Steps:
a) Create a VBC based on class “CSSFABCVRec”.
b) Create VBC fields, the Parent Buscomp link and add it into BO.
c) Create an Integration Object based on the VBC created.
Note: this integration object must be contain just one Integration Component based on the VBC created on previous step
d) Create a Business Service based on class “CSSFAExternalService”.
e) Into the BS create a method called “Query”.
f) Into the VBC create the next User Properties:
Name: Value
Outgoing Integration Object Name: Name of the IO previously created
ProcessName: Name of the Workflow Process to be invoked
Service Name: Name of the BS previously created
Enable Caching: N
g) Create an applet based on the VBC. Add this applet to your custom view.
h) If you need to pass arguments to the WF, you can put a little of script into the PreQuery Method of VBC Server Script (for example, set a ProfileAttr

Middle wares:
IBM-WPS, WMB, WTX (Mercator)
webMethods
TIBCO

SCRIPTING PART OF VBC:

 VIRTUAL BUSINESS COMPONENT:




Business Component: Any Name
Class: CSSBCVExtern

Business Component User Property:

Name: Service Name

Value: Business Service Name


function Service_PreInvokeMethod (MethodName, Inputs, Outputs)


{

var iOperation = ContinueOperation;

var strMethodInit = "Init";

var strMethodQuery = "Query";



var s = Inputs.GetProperty("Operation");



switch(MethodName)

{

case strMethodInit:

iOperation = Init(Inputs,Outputs);

break;

case strMethodQuery:

Query(Outputs);

iOperation = CancelOperation;

break;

case "Update":

case "PreInsert":

//case "Insert":

//case "Delete":

iOperation = CancelOperation;

break;

default:

break;

}

return iOperation;

}







function Init(Inputs, Outputs)


{

var iOperation = CancelOperation;



try

{

Outputs.SetProperty("Opportunity Name_KC", "");

Outputs.SetProperty("Description_KC", "");

Outputs.SetProperty("Name_KC", "");

Outputs.SetProperty("Status_KC", "");

Outputs.SetProperty("Estimated Close Date_KCIB_KC", "");

Outputs.SetProperty("System Generated Flag_KC", "");

Outputs.SetProperty("Opportunity Row_Id", "");

Outputs.SetProperty("Probability of Close_KCIB_KC", "");

Outputs.SetProperty("Product", "");

return (iOperation);

}

catch (e)

{

var strErrMsg = e.toString();

TheApplication().RaiseErrorText(strErrMsg);

}

finally

{

}

}







function Query(Outputs)


{

try

{

var psPropSet = TheApplication().NewPropertySet();

var strHH_Id = TheApplication().GetProfileAttr("HH_VBC_ID_KC"); // PA set in Household BC

var boHH; // BO for Households

var bcHHOpptys; // BC for HH Assets/Calls

var bcPrtyRel; // BC for Members

var blnFound1; // Found Member record

var blnFound2; // Found Oppty records

var blnFound3; // Found Oppty private records

var strArray = new Array; // Used for deduping the VBC accounts/rows

var i=0; // Integer for Array indices

var todayDate = new Date;

var Days365Ago = AddToDate(todayDate,90,0,0,0,-1);

var strDateSearch = DateToString(Days365Ago);





{

//Find Household Members- 'Party Relationship To' BusComp

var searchexpr = "[Party Id] = '" + strHH_Id + "' AND ([Relationship Type] = 'PRIMARY CLIENT' OR [Relationship Type] = 'RELATED CLIENT')";

boHH = TheApplication().GetBusObject("Household");

bcPrtyRel = boHH.GetBusComp("Party Relationship To");

bcPrtyRel.ClearToQuery();

bcPrtyRel.ActivateField("Related Party Contact Full Name");

bcPrtyRel.ActivateField("Related Party Business Name");

bcPrtyRel.ActivateField("Related Party Id");

bcPrtyRel.ActivateField("Related Party Type");

bcPrtyRel.SetViewMode(AllView);

//bcPrtyRel.SetSearchSpec("Party Id", strHH_Id); //jrh - commented out 10/14/08

bcPrtyRel.SetSearchExpr(searchexpr);

bcPrtyRel.ExecuteQuery(ForwardBackward);



if(bcPrtyRel.FirstRecord())

{

blnFound1 = bcPrtyRel.FirstRecord();

// Cycle thru each Member Record.....

while (blnFound1)

{

//LogMessage(bcPrtyRel.GetFieldValue("Related Party Id") +":"+ bcPrtyRel.GetFieldValue("Related Party Type")+"
"+bcPrtyRel.GetFieldValue("Related Party Contact Full Name")+"
"+bcPrtyRel.GetFieldValue("Related Party Business Name"));

var strSearchPerson = "[Key Contact Id] = '" + bcPrtyRel.GetFieldValue("Related Party Id") + "' AND [Secure Flag] <> 'Y'";

var strSearchOrg = "[Account Id] = '" + bcPrtyRel.GetFieldValue("Related Party Id") + "' AND [Secure Flag] <> 'Y'";

var strSearchAddl = "AND (([Status] = 'ENGAGED' OR [Status] = 'IN PROCESS' OR [Status] = 'AVAILABLE') OR (([Status] = 'REJECTED' OR [Status] = 'CLOSED' OR [Status] = 'WITHDRAWN' OR [Status] = 'LOST') AND [Primary Revenue Close Date]>= '" + strDateSearch +"'))";

var finalstrSearchOrg = strSearchOrg + strSearchAddl;

var finalstrSearchPerson = strSearchPerson + strSearchAddl;

// Now Find first Opptys assoc with Members.

bcHHOpptys = boHH.GetBusComp("Opportunity Skinny_KC");

bcHHOpptys.ClearToQuery();

bcHHOpptys.ActivateField("Business_KC");

bcHHOpptys.ActivateField("Description");

bcHHOpptys.ActivateField("Estimated Close Date_KCIB_KC");

bcHHOpptys.ActivateField("Key Contact First Name");

bcHHOpptys.ActivateField("Key Contact Last Name");

bcHHOpptys.ActivateField("Name");

bcHHOpptys.ActivateField("Status");

bcHHOpptys.ActivateField("Secure Flag");

bcHHOpptys.ActivateField("Id");

bcHHOpptys.ActivateField("System Generated Flag_KC");

bcHHOpptys.ActivateField("Master Status_KC");

bcHHOpptys.ActivateField("Key Contact Id");

bcHHOpptys.ActivateField("Account Id");

bcHHOpptys.ActivateField("Probability of Close_KCIB_KC");

bcHHOpptys.ActivateField("Product");

bcHHOpptys.SetViewMode(AllView);



if (bcPrtyRel.GetFieldValue("Related Party Type") == 'Person')

{

//bcHHOpptys.SetSearchExpr("[Key Contact Id] = '" + bcPrtyRel.GetFieldValue("Related Party Id") + "' AND [Secure Flag] <> 'Y'");// AND [Master Status_KC] = 'A'");

bcHHOpptys.SetSearchExpr(finalstrSearchPerson);



}

else if (bcPrtyRel.GetFieldValue("Related Party Type") == 'Organization')

{

//bcHHOpptys.SetSearchExpr("[Account Id] = '" + bcPrtyRel.GetFieldValue("Related Party Id") + "' AND [Secure Flag] <> 'Y'");// AND [Master Status_KC] = 'A'");

bcHHOpptys.SetSearchExpr(finalstrSearchOrg);



}

bcHHOpptys.ExecuteQuery(ForwardOnly);



if(bcHHOpptys.FirstRecord())

{

blnFound2 = bcHHOpptys.FirstRecord();

// Cycle thru each Account Record.....

while (blnFound2)

{ // Rec Found... Populate HH Accounts VBC.

if (bcPrtyRel.GetFieldValue("Related Party Type") == 'Person')

{

strArray[i] = bcPrtyRel.GetFieldValue("Related Party Type") + "
" + bcHHOpptys.GetFieldValue("Estimated Close Date_KCIB_KC") + "
" + bcHHOpptys.GetFieldValue("Id") + "
" + bcHHOpptys.GetFieldValue("Description") + "
" + bcPrtyRel.GetFieldValue("Related Party Contact Full Name") + "
" + bcHHOpptys.GetFieldValue("Name") + "
" + bcHHOpptys.GetFieldValue("Status") + "
" + bcHHOpptys.GetFieldValue("System Generated Flag_KC") + "
" + bcHHOpptys.GetFieldValue("Probability of Close_KCIB_KC") + "
" + bcHHOpptys.GetFieldValue("Product") + "
" + bcHHOpptys.GetFieldValue("Master Status_KC") + "
" + bcHHOpptys.GetFieldValue("Business_KC") + "
" + bcHHOpptys.GetFieldValue("Key Contact Last Name") + "
" + bcHHOpptys.GetFieldValue("Key Contact First Name") + "
";

i = i + 1;

}

else if (bcPrtyRel.GetFieldValue("Related Party Type") == 'Organization')

{

strArray[i] = bcPrtyRel.GetFieldValue("Related Party Type") + "
" + bcHHOpptys.GetFieldValue("Estimated Close Date_KCIB_KC") + "
" + bcHHOpptys.GetFieldValue("Id") + "
" + bcHHOpptys.GetFieldValue("Description") + "
" + bcPrtyRel.GetFieldValue("Related Party Business Name") + "
" + bcHHOpptys.GetFieldValue("Name") + "
" + bcHHOpptys.GetFieldValue("Status") + "
" + bcHHOpptys.GetFieldValue("System Generated Flag_KC") + "
" + bcHHOpptys.GetFieldValue("Probability of Close_KCIB_KC") + "
" + bcHHOpptys.GetFieldValue("Product") + "
" + bcHHOpptys.GetFieldValue("Master Status_KC") + "
" + bcHHOpptys.GetFieldValue("Business_KC") + "
" + bcHHOpptys.GetFieldValue("Key Contact Last Name") + "
" + bcHHOpptys.GetFieldValue("Key Contact First Name") + "
";

i = i+ 1;

}

//i = i + 1;

blnFound2 = bcHHOpptys.NextRecord();

} // While blnFound2 loop

} // If bcHHOpptys first rec loop



//LAP 4/22/9 - added per CL 9672 R2.19

// Now Find first Private Opptys assoc with Members.

bcHHOpptys = boHH.GetBusComp("Opportunity Skinny_KC");

bcHHOpptys.ClearToQuery();

bcHHOpptys.ActivateField("Business_KC");

bcHHOpptys.ActivateField("Description");

bcHHOpptys.ActivateField("Estimated Close Date_KCIB_KC");

bcHHOpptys.ActivateField("Key Contact First Name");

bcHHOpptys.ActivateField("Key Contact Last Name");

bcHHOpptys.ActivateField("Name");

bcHHOpptys.ActivateField("Status");

bcHHOpptys.ActivateField("Secure Flag");

bcHHOpptys.ActivateField("Id");

bcHHOpptys.ActivateField("System Generated Flag_KC");

bcHHOpptys.ActivateField("Master Status_KC");

bcHHOpptys.ActivateField("Key Contact Id");

bcHHOpptys.ActivateField("Account Id");

bcHHOpptys.ActivateField("Probability of Close_KCIB_KC");

bcHHOpptys.ActivateField("Product");

bcHHOpptys.SetViewMode(ManagerView);



strSearchPerson = "[Key Contact Id] = '" + bcPrtyRel.GetFieldValue("Related Party Id") + "' AND [Secure Flag] = 'Y'";

strSearchOrg = "[Account Id] = '" + bcPrtyRel.GetFieldValue("Related Party Id") + "' AND [Secure Flag] = 'Y'";

strSearchAddl = "AND (([Status] = 'ENGAGED' OR [Status] = 'IN PROCESS' OR [Status] = 'AVAILABLE') OR (([Status] = 'REJECTED' OR [Status] = 'CLOSED' OR [Status] = 'WITHDRAWN' OR [Status] = 'LOST') AND [Primary Revenue Close Date]>= '" + strDateSearch +"'))";

finalstrSearchOrg = strSearchOrg + strSearchAddl;

finalstrSearchPerson = strSearchPerson + strSearchAddl;



if (bcPrtyRel.GetFieldValue("Related Party Type") == 'Person')

{

bcHHOpptys.SetSearchExpr(finalstrSearchPerson);

}

else if (bcPrtyRel.GetFieldValue("Related Party Type") == 'Organization')

{

bcHHOpptys.SetSearchExpr(finalstrSearchOrg);

}

bcHHOpptys.ExecuteQuery(ForwardOnly);



if(bcHHOpptys.FirstRecord())

{

blnFound3 = bcHHOpptys.FirstRecord();

// Cycle thru each Oppty Record.....

while (blnFound3)

{ // Rec Found... Populate HH Oppty VBC.

if (bcPrtyRel.GetFieldValue("Related Party Type") == 'Person')

{

strArray[i] = bcPrtyRel.GetFieldValue("Related Party Type") + "
" + bcHHOpptys.GetFieldValue("Estimated Close Date_KCIB_KC") + "
" + bcHHOpptys.GetFieldValue("Id") + "
" + bcHHOpptys.GetFieldValue("Description") + "
" + bcPrtyRel.GetFieldValue("Related Party Contact Full Name") + "
" + bcHHOpptys.GetFieldValue("Name") + "
" + bcHHOpptys.GetFieldValue("Status") + "
" + bcHHOpptys.GetFieldValue("System Generated Flag_KC") + "
" + bcHHOpptys.GetFieldValue("Probability of Close_KCIB_KC") + "
" + bcHHOpptys.GetFieldValue("Product") + "
" + bcHHOpptys.GetFieldValue("Master Status_KC") + "
" + bcHHOpptys.GetFieldValue("Business_KC") + "
" + bcHHOpptys.GetFieldValue("Key Contact Last Name") + "
" + bcHHOpptys.GetFieldValue("Key Contact First Name") + "
";

i = i + 1;

}

else if (bcPrtyRel.GetFieldValue("Related Party Type") == 'Organization')

{

strArray[i] = bcPrtyRel.GetFieldValue("Related Party Type") + "
" + bcHHOpptys.GetFieldValue("Estimated Close Date_KCIB_KC") + "
" + bcHHOpptys.GetFieldValue("Id") + "
" + bcHHOpptys.GetFieldValue("Description") + "
" + bcPrtyRel.GetFieldValue("Related Party Business Name") + "
" + bcHHOpptys.GetFieldValue("Name") + "
" + bcHHOpptys.GetFieldValue("Status") + "
" + bcHHOpptys.GetFieldValue("System Generated Flag_KC") + "
" + bcHHOpptys.GetFieldValue("Probability of Close_KCIB_KC") + "
" + bcHHOpptys.GetFieldValue("Product") + "
" + bcHHOpptys.GetFieldValue("Master Status_KC") + "
" + bcHHOpptys.GetFieldValue("Business_KC") + "
" + bcHHOpptys.GetFieldValue("Key Contact Last Name") + "
" + bcHHOpptys.GetFieldValue("Key Contact First Name") + "
";

i = i+ 1;

}

//i = i + 1;

blnFound3 = bcHHOpptys.NextRecord();

} // While blnFound3 loop

} // If bcHHOpptys first rec loop

//LAP 4/22/9 - END OF CODE added per CL 9672 R2.19





blnFound1 = bcPrtyRel.NextRecord();

} // While blnFound1 loop







} // If bcPartyRel first rec loop



// from here to Catch e Is New & Used for Deduping Accts

// Sort the Array with data....

strArray.sort();

strArray.reverse();



var pos; //Represents position of string strArray[i]

var strId = "";

var strDescription = "";

var strEstimatedCloseDate_KCIB_KC = "";

var strName = "";

var strOpptyName = "";

var strStatus = "";

var strSysGenFlag = "";

var strSecureFlag = "";

var strProbabilityofClose_KCIB_KC = "";

var strProduct = "";

var strDescription_0 = "";

var strEstimatedCloseDate_KCIB_KC_0 = "";

var strName_0 = "";

var strOpptyName_0 = "";

var strStatus_0 = "";

var strSysGenFlag_0 = "";

var strSecureFlag_0 = "";

var MasterStatus = "";

var partyType = "";

var strBusName = "";

var strLName = "";

var strFName = "";

var strFullName = "";





for (var j = 0; j < strArray.length; j++)

{ // Start Loop

psPropSet = TheApplication().NewPropertySet();

pos = 0; //Initialize the position for each pass.



// **** READ ARRAY VALUES

partyType = strArray[j].substring(pos, strArray[j].indexOf("
", pos));

pos = pos + partyType.length + 1;



strEstimatedCloseDate_KCIB_KC = strArray[j].substring(pos, strArray[j].indexOf("
", pos));

pos = pos + strEstimatedCloseDate_KCIB_KC.length + 1;



strId = strArray[j].substring(pos, strArray[j].indexOf("
", pos));

pos = pos + strId.length + 1;



strDescription = strArray[j].substring(pos, strArray[j].indexOf("
", pos));

pos = pos + strDescription.length + 1;



strName = strArray[j].substring(pos, strArray[j].indexOf("
", pos));

pos = pos + strName.length + 1;



strOpptyName = strArray[j].substring(pos, strArray[j].indexOf("
", pos));

pos = pos + strOpptyName.length + 1;



strStatus = strArray[j].substring(pos, strArray[j].indexOf("
", pos));

pos = pos + strStatus.length + 1;



strSysGenFlag = strArray[j].substring(pos, strArray[j].indexOf("
", pos));

pos = pos + strSysGenFlag.length + 1;



strProbabilityofClose_KCIB_KC = strArray[j].substring(pos, strArray[j].indexOf("
", pos));

pos = pos + strProbabilityofClose_KCIB_KC.length + 1;



strProduct = strArray[j].substring(pos, strArray[j].indexOf("
", pos));

pos = pos + strProduct.length + 1;



MasterStatus = strArray[j].substring(pos, strArray[j].indexOf("
", pos));

pos = pos + MasterStatus.length + 1;



strBusName = strArray[j].substring(pos, strArray[j].indexOf("
", pos));

pos = pos + strBusName.length + 1;



strLName = strArray[j].substring(pos, strArray[j].indexOf("
", pos));

pos = pos + strLName.length + 1;



strFName = strArray[j].substring(pos, strArray[j].indexOf("
", pos));



strFullName = strFName + " " + strLName;





// LogMessage(" ****** "+j + ": " + strArray[j]);

// LogMessage("Prod Old: "+strId_0);

// LogMessage("Prod New: "+strId);



if (strDescription != strDescription_0

strEstimatedCloseDate_KCIB_KC != strEstimatedCloseDate_KCIB_KC_0

strName != strName_0

strOpptyName != strOpptyName_0

strStatus != strStatus_0

strSysGenFlag != strSysGenFlag_0

strSecureFlag != strSecureFlag_0)

{

psPropSet.SetProperty("Opportunity Name_KC", strOpptyName);

psPropSet.SetProperty("Description_KC", strDescription);

psPropSet.SetProperty("Status_KC", strStatus);

psPropSet.SetProperty("Estimated Close Date_KCIB_KC", strEstimatedCloseDate_KCIB_KC);

psPropSet.SetProperty("System Generated Flag_KC", strSysGenFlag);

psPropSet.SetProperty("Opportunity Row_Id", strId);

psPropSet.SetProperty("Probability of Close_KCIB_KC", strProbabilityofClose_KCIB_KC);

psPropSet.SetProperty("Product", strProduct);

psPropSet.SetProperty("Master Status_KC",MasterStatus);

/*HRM this conditions added because LOB wanted both contact and Business Name in the child records*/

if(partyType == 'Organization')

{

psPropSet.SetProperty("Name_KC", strName);

psPropSet.SetProperty("Contact Full Name",strFullName);

}

else if(partyType == 'Person')

{

psPropSet.SetProperty("Name_KC", strBusName);

psPropSet.SetProperty("Contact Full Name",strName);

}

Outputs.AddChild(psPropSet);

//LogMessage("Added: "+strProd+"
"+strAcctNbr+"
"+strName+"
"+strReltnshp+"
"+strStatus+"
"+strBankNbr);



strDescription_0 = strDescription;

strEstimatedCloseDate_KCIB_KC_0 = strEstimatedCloseDate_KCIB_KC;

strName_0 = strName;

strOpptyName_0 = strOpptyName;

strStatus_0 = strStatus;

strSysGenFlag_0 = strSysGenFlag;

}

} // FOR Loop

} //end if strHH_Id

}

catch (e)

{

var strErrMsg = e.toString();

TheApplication().RaiseErrorText(strErrMsg);

}

finally

{

//Clean up after yourself....

bcPrtyRel = null;

bcHHOpptys = null;

boHH = null;

psPropSet = null;

}

}







function LogMessage (Inputs)

//*******************************************************

//Description : Function logs messages to output file

//Created : 14/3/8

//Modification History:

//*******************************************************

{

var Msg = Inputs;

//var m_logFile = "\\Siebel\\siebsrvr\\log\\HH_CallRpts_VBC.txt"

var m_logFile = ".\\..\\log\\HH_CallRpts_VBC.txt"; //SK changed logpath 05-18-2010



// if (TheApplication().GetProfileAttr("EAI_INBOUND_LOG") == "ON")

// {

var fp = Clib.fopen (m_logFile, "at+");

if (fp != null)

{

Clib.fputs(Msg, fp);

Clib.fputs("\n", fp);

Clib.fclose(fp);

}

// }

}