Saturday 13 October 2012

Siebel - DeleteRecord Method in eScript

Let me take this opportunity to share a unique issue that I faced during one small requirement development.

Requirement: Contacts with a specific roles are created due a configuration miss in the EAI. As the product is live the fix can be put only after the root cause is found and change window is available. Till then these records needs to be deleted. As the number of records is huge deleting these records manually is a time consuming task and no back end deletion is allowed as the product is live. As a work around a client side BS would be developed to over come the problem.

Siebel  Version : 7.7

Below is the pseudo code

BusCom = "TechLabHelp"
With BusCom
               clear Query()
               Search for Contact with Role "TECHLABS"
               FirstRec = FirstRecord
               While (FirstRec)
                       FirstRec = DeleteRecord
               End While
End With

Hope pseudo code is simple and self explanatory. Now let me show how the Siebel eScript looked like.


.............

BusComp = "TechLabHelp"
With BusComp
{
    ClearToQuery();
    SetSearchSpec("Type", "TECHLABS");
    ExecuteQuery(ForwardOnly);
    var FirstRec=FirstRecord();
    while(FirstRec)
    {
     FirstRec = DeleteRecord();
     }
}
..................


Not sure why but the above code would always delete only one record form the query result. Also as a best practice and as said by Siebel Bookshelf NextRecord method cannot be used after DeleteRecord as the cursor is moved to next record by default. I was totally not sure if I had a way to resolve this. However logically it can be resolved by having one more While loop and keep the count of records, delete the records until count goes to zero. But Two while loops is not a good idea as it consumes a lot of resources.

So how did I resolve the issue is as below.


.............

BusComp = "TechLabHelp"
With BusComp
{
    ClearToQuery();
    SetSearchSpec("Type", "TECHLABS");
    ExecuteQuery(ForwardOnly);
    var FirstRec=FirstRecord();
    while(FirstRec)
    {
     FirstRec = DeleteRecord();
     //This did the trick. The Cursor would always be reset to First record and the deletion went fine.
    FirstRec=FirstRecord();
     }
}
..................

Its simple but took good amount of time to find the issue.

Will try to share similar posts going forward.

Monday 1 October 2012

Learn basics of Vb.Net in 10 Simple Posts - Part 2



Welcome back to Learn basics of VB.Net in ten Simple posts. This is the second post in the series and we shall see some more useful ways of using VB.Net and also see how we can improve our first project to do more.  In this post I will be showing how to add a TextBox, Label and also how a little bit coding.

Before we begin lets understand what is Text box and a Label. In simple terms we can say TextBox is a Object where you can Enter a value or Diplay a value and Label would act like a Tag for the Text box showing what data is represented by a TextBox or any other GUI object. For example in the below User Name and Password act as a Label for Textboxs. Where to use what is decided by the requirement.


Now that we know what a Label and a Text box is let us continue with our project.

1. Add two label and two text boxes from Toolbox and arrange them as shown below


2. Change the Text property of Label1 and Label2 to First Name: and Last Name: respectively. The labels might require a slight alignment. Now the form should like this.


3. Now let us read the value from the Labels and display Hellow message. To do this we will have to modify the code behind the Say !! Hellow Button. double click on the Button in design mode we should able to see the code behind it. Add the below line of code and remove any extra code that was created previously

MessageBox.Show("Hellow !!!! " & TextBox1.Text & vbTab _
                        & TextBox2.Text, "Welcome to TechLabs")

Complete code should look as below


By now you must be wondering previously we used MsgBox to display message and now we are using MessageBox.Show to display message box. MsgBox is VB6 kind of message box and MessageBox.Show is VB.Net method both are equally useful. 

The Method MessageBox.Show would take different parameters I will discuss a few of them, first parameter value is the display message and second is the Title of the message box. similarly there are other parameters which we can discuss as required.

So the display message is "Hellow !!!! " & TextBox1.Text & vbTab & TextBox2.Text, lets understand part by part. First part "Hellow !!! " is a static text and & is used to concatenate the string a very useful and most commonly used one. TextBox1.Text would give the value entered from the Text box and vbTab is to add a space between the Strings. Its simple until we try it.

once the code is added save it and debug. On clicking Say !!! Hellow button the bellow message should be displayed.


4. Congrats now you have successfully completed your second exercise. Tune in for more.