Tuesday, April 28, 2009

FirstRecord() in PreCanInvoke Event : Refresh Issue

Today I am going to tell you about an interesting issue that we faced in our Production Env and really worked hard to figure it out the root cause for it.


The issue was :

On Activity Form applet, we have "Comments" field, which is 2000 characters long and user to write a detail description in this field related to that activity record. Now few of the users faced the issue that "while typing some text in Comments field, suddenly the whole text written get deleted and Comments field become blank". User get frustrated as he need to type in the whole text again and also the next time not sure whether he will able to complete putting text in Comments field or not. For a temporary workaround they used to first type in all the text in a NotePad file and then copy paste the complete text at once in Comments field and save the record.

What we tried :

When we tried replicating this issue in our dedicated env, we were unable to replicate it. After lot much of effort our QA Team was able to replicate it sometimes on our thin client. But the problem was this is not always happening with them as well. On some of the machines we were not able to replicate it at all. Totally a random behaviour.

Now the problem was to find out the steps so that we can replicate it. We have one option to try i.e. by disabling all the Server Script and check if we can replicate the issue in thin client (since in dedicated client everything was working fine).

We changed the "EnableScripting" = False and restart the Siebel server, and found that the issue is not coming anymore. So we narrowed down for the root cause of the problem to Scripting.


And, here is what we finally found :

On PreCanInvoke method of the applet we had a script written, something like :


if (MethodName == "Test")
{
if(this.BusComp().FirstRecord())
CanInvoke = "True";
return (CancelOperation);
}


So, what was happening when user was typing some text in Comments field, it seems like IE web page get refreshed and due to this the code written on "PreCanInvoke" method was getting invoked and due to the "FirstRecord()" method used inside the code, the current record get refreshed and resulting in no text in Comments field.

Finally, we were able to find the root cause of the problem, now its the time to look for some workaround. So we decided not to enable/disable button using PreCavInvoke script, rather put a check message in PreInvoke method when there is no record displayed. So here below is final version of script we used :

PreCanInvoke Method

if (MethodName == "Test")
{

CanInvoke = "True";
return (CancelOperation);

}


PreInvoke Method :

if(MethodName == "Test")
{
if(this.BusComp().FirstRecord())
{
TheApplication().RaiseErrorText("This operation is not valid, when record is not displayed");

}
return (CancelOperation);
}


Recommendation:
Avoid writing scripting on PreCanInvoke Method of Applet, as this is the event which fires on each and every action we do on the applet + at the time of automatic refresh of web page.

3 comments:

  1. Hai iam facing one issue,we know that one contact person can speak many languages.As well that have primary language for that contact. so iam creating new mvg for contact language.so NOw Issue is that whether I need create new bc for this using s_contact_x table based. or we can create link to that contact/contact. I here is my problem how can show source and destination fields for that link. can u give me the way How can i approach for this.

    ReplyDelete
  2. If I understood your requirement correctly, here is the solution for your problem :
    1. Create a new BC (Contact Language) on S_CONTACT_XM table with some searchspec say : "[Type] = "Languages"". Make sure you should expose Parent Row Id (PAR_ROW_ID) and Type (TYPE) field in it.
    2. Create a link between Contact and Contact Language with the following properties:
    a) Parent Business Component : Contact
    b) Child Business Component : Contact Language
    c) Source Field : Id
    d) Destination Field : Parent Row Id
    e) Create a MVL in Contact BC where destination BC is "Contact Language" and use the link created above.

    hope it helps.

    ReplyDelete
  3. Hi,

    If i understand your requirement correctly, the goal is to disable the button when there are no records on that applet. I think the below script works :


    if (MethodName == "Test")
    {
    if((this.BusComp().GetFieldValue("Id")!= "")&& (this.BusComp().GetFieldValue("Id")!= null))
    {
    CanInvoke = "True";
    return (CancelOperation);
    }
    }

    ReplyDelete