Friday, November 23, 2007

Siebel Business Component Outer Join - How Important?

Siebel Business Component Outer Join - How Important?

working on Siebel I have come across lot of situations where just one little miss can wreck havoc with the application. It can result in performance issues and Data issues. I think some of you might have guessed by know what miss I am talking about.I am talking about Outer Join Flag on Join Section of the Business Component. Joins are the integral part of Siebel configuration. They are indispensable, joins are required because we know the database (it can be oracle, DB2 or Microsoft SQL Server) is a relational database known as RDBMS in short form. Which means the information that resides in it is in the form of related tables and we always need information of one table in another. These tables are related with the help of Foreign Keys (FK). So, when we want to show information of one table in another we use Joins and we use them all the times. When we are creating Joins in Siebel you can see a field called Outer Join Flag. Please see the screenshot below.
and every time we don’t check that flag we are heading for trouble.
Now, what exactly does that flag represent? Before I explain it I assume that you have basic understanding of SQL and simple joins. As I have mentioned earlier that everything that configure or do on UI is converted into SQL and that is where this flag comes into picture.For example see the simple sql pulling data from another table with the help of simple joinselect name b
from siebel.s_opty a, siebel.s_doc_quote b
where b.par_row_id = a.row_id
and a.somefield = b.somefield
and a.row_id = ‘Some Id’Now this SQL is suppose to select name of the quote where the par_row_id column (which store row id of its parent) is equal to the row if of opportunity and in addition to that somefield of opportunity is equal to some field of quote. Now we assume that you had created a join between Opportunity-Quote and forgot to check the outer join flag.You will be amazed to see that there are No Records on UI. The reason being it will try to match the exact values in the field and any record that is a not a match will be discarded. Which means if there are some records that have no value in ’somefield’ either in Opportunity or on Quote will be discarded. What if we want those records to shown? We have to check the Outer join flag which will result in a query as given belowselect name b
from siebel.s_opty a, siebel.s_doc_quote b
where b.par_row_id = a.row_id
and a.somefield = b.somefield(+)


and a.row_id = ‘Some Id’Which will result in all the Quotes that have ‘Some Id’ in par_row_id or in simple terms that have Opportunity Id with ‘Some Id’ as their parent.My experience has taught me to ask this as the first question whenever I face problem mentioned above and I have seen developers sweat over this kind of problem for hours before they spot it. I will mention some real life situations I have faced which were due this little (or rather huge) miss while doing configuration.Examples - Real Life Situations:
We have developed a web service that resulted in the insertion of quotes from a Java Application. When we inserted a quote it got inserted successfully and when we tried to update it, it Failed. It took us almost a day to find out that a developer had created a new join in business component and forgot to check that Outer Join flag which resulted in update to failed as it was not able to fetch that record.I had created a new View in Assets Screen.
When user was in My Assets view then he was able to see the records but as soon as he choose All view the records disappeared. The reason same a new join and forgot to check Outer join flag.Whenever you face this kind of problem go through logs and more often than not you will find this as your root cause.

Siebel Workflow

Siebel CRM How To - Invoke Workflow through BC User Property

Till siebel 7.5 the only method know to invoke workflows were

  • Runtime Events in start step of workflow
  • Business Service
  • Business Component Script
  • Workflow Policies

But from Siebel 7.7 ownwards there is one more method by which we can invoke a workflow. That way is Siebel business Component user property. You can 'Named Methodn' user property in a BC which can invoke a workflow where n is increment to the last named method user property defined on that BC.Name: Named Method Value:[Event Name] , "INVOKESVC", , "Workflow Process Manager", "RunProcess", 'ProcessName',[Name of the Workflows] , 'RowId', [Row Id Value]Example The below mentioned will invoke a workflow named 'Example Workflow' when a new record is created in Example BC.Name: Named Method 1Value: "New Record", "INVOKESVC", "Example", "Workflow Process Manager", "RunProcess", "'ProcessName'", "Example Wrokflow", "'RowId'", "[Id]"

Siebel CRM - How To Call a Workflow Asynchronously? (Part-1)

This Article is about Siebel CRM 7.X Workflows and Runtime Events. It tells you how can we use them to our advantage.
We all want the response time of our Application to be as fast as it can and we do everything that we can to achieve that. I am going to tell you about a way which can help you to reduce the response time without actually reducing any functionality. Siebel can execute workflows in two ways.

  • Synchronous
  • Asynchronous

Synchronous Execution: When workflows are executed Synchronously then user gets the control back only when the workflow has finished it execution.Asynchronous Execution: When workflows are executed Asynchronously then user gets back the control immediately and the workflow is submitted to workflow process manager (WPM) as a job to be executed. WPM then executes the job later.Often we have a functionality where large amount of processing needs to be done on an object which user is not going to use access right now. I can explain it with an example.When user clicks copy button on a opportunity or quote we want certain custom entities to be copied over but which user will not access at that time but later. So, we can reduce our response time by just copying the quote or opportunity synchronously and placing the code of copying of custom entities in workflow and executing that workflow asynchronously.There are two way to execute a workflow asynchronously

  • Workflow Policy
  • Runtime Event and Business Service (BS) Combination

Workflow Policy is pretty traditional method of executing a workflow process.
You create a policy. Enter the conditions Specify the workflow to be executed Generate Triggers






I wouldn't go into details of creating a policy but I will tell you some disadvantages of using Workflow Policy

  1. Slow Execution
  2. Difficult to setup
  3. Not Reliable and Error Prone

But from Siebel 7.7 onwards we have another more robust, efficient and quicker way to do that which is Runtime Events and Business Service.

Runtime Events Workflows - Part 2

This Article is about Siebel CRM 7.X Workflows and Runtime Events. It tells you how can we use them to our advantage.
In this article I will tell you about the actual process of Setting up Runtime Event and Business Service assuming you have working knowledge of both. If you want to know the basics of these please see other posts of my blog.

Just one important thing that you should know about runtime events is that they are executed even before the Business Component Events.

To explain it better I am taking an example where our requirement is to execute a workflow when you click Submit Oppty button on Opportunity Form Applet.

  1. Go to Administration ==>Runtime Events Screen
  2. Go to Action Sets View
  3. Create a New Record in the Action Set View of Runtime Events Administration Screen
  4. Enter Any Name in the Name Field of the Action Set List Applet
  5. Create New Record List Applet Below it
  6. Enter

Name = "TestRuntimeEvent" ;
Action Type = "Business Service" ;
Sequence = "1"

  1. In the Form Applet Below Enter the Following Details Business Service = "TestBS" ; Business Service Method = "TestMethod"8. Click Menu ==> Reload Runtime Events Make Sure that you have Active Flag checked in both List Applets.

You are done in Action Set View. Now Go to Events view and Follow the steps given below

  1. Click New and Enter the Following Information

Sequence = 1 ;
Object Type = "Applet" ;
Object Name = "Opportnity Form Applet" ;
Event = "InvokeMethod" ;
Sub Event = "Submit Oppty" ;
Action Set = "TestRunTimeEvent"

Conditional Expression should be given if you want the restrict the execution of this Runtime Event to certain conditions and Action Set Name is always the name of the action set that we created.2. Click Menu ==> Reload Runtime Events.
* Everytime you make a change to runtime events you have to Reload them to activate the changes that you have made.Now we are through the Runtime Event parts.What we have done so far is that When user clicks Submit Oppty button it is going to call BS named TestBS with method as "TestMethod".Now we are going to write the code in the busines service which will actually result in the execution of Workflow Process Asynchronously.

  1. Go To Administration ==> Business Service
  2. Create a Business Record with name "TestBS"
  3. Create a Record in List Applet for Service_PreInvokeMethod and choose Programming Langauge as "eScript"

Write the Following code in Code Window inside the function Service_PreInvokeMethod
if(MethodName == "TestMethod")
{
var svc;
var child;
var input;
var output;
var rowid;
var bo = TheApplication().ActiveBusObject();
var bc = bo.GetBusComp("Opportunity");
// Change the BusComp name with the name of the BusComp you want to execute the workflow with
svc = TheApplication().GetService("Asynchronous Server Requests");
// Don't change this - Actual BS that is responsible for submitting a job to WPM
input = TheApplication().NewPropertySet();
child = TheApplication().NewPropertySet();
output = TheApplication().NewPropertySet();
input.SetProperty("Component", "WfProcMgr");
rowid = bc.GetFieldValue("Id");
// We would like to pass the row id of the Current record on which the user is working - You can pass more than one arguments
child.SetProperty("ProcessName", "Service Agreement - Agreement Status");
// Workflow process you want to execute
child.SetProperty("RowId", rowid);
// passing the values
input.AddChild(child);
svc.InvokeMethod("SubmitRequest", input, output);
/// invoking the business service method
svc = null;
// nullfiying the objects
child = null;
output = null;
input = null;
return(CancelOperation);
}

And you are done!!!!!!!!!