try-catch-finally and throw – Final Part

OkAvarageGoodVery GoodExcellent (7 votes, average: 4.43 out of 5)
Loading ... Loading ...
Viewed : 4,605 times

Related Posts

  • newbie

    Hi Neel,

    Thanks for the post…could you please explain regarding the -1 in the if statement..

    thanks in advance..

  • newbie

    Hi Neel,

    Thanks for the post…could you please explain regarding the -1 in the if statement..

    thanks in advance..

  • http://siebelunleashed.com/ neel

    indexOf function returns -1 if the specified string is not found and if it found then it returns the starting point of the string

    So, -1 here means some other error has occured so, show the error message and in case if it contains the error message we want to suppress it will return a positive number denoting position of error code hence no error message and the error is suppressed.

  • http://siebelunleashed.com neel

    indexOf function returns -1 if the specified string is not found and if it found then it returns the starting point of the string

    So, -1 here means some other error has occured so, show the error message and in case if it contains the error message we want to suppress it will return a positive number denoting position of error code hence no error message and the error is suppressed.

  • Divya

    Thanks a ton Neel…:)

  • Divya

    Thanks a ton Neel…:)

  • Srinivas

    Hi Neel,

    Can you give me details about “How To make sure that memory is released or not once objects are nullified through script”

    Thanks
    Srinivas

  • Srinivas

    Hi Neel,

    Can you give me details about “How To make sure that memory is released or not once objects are nullified through script”

    Thanks
    Srinivas

  • Maria Duque

    Hi, Can you tell me details of the Siebel´s Reports Module?

    Thanks!

  • Maria Duque

    Hi, Can you tell me details of the Siebel´s Reports Module?

    Thanks!

  • NS

    i have a question, I have seen at times that developers write

    catch(e)
    {
    Throw(e);
    TheApplication().RaiseErrorText…..
    }
    I belive that in the above code Raise Error wont get fired..since throw e will cancel the opeartion there..
    Help me understanding it.

    Regards

  • NS

    i have a question, I have seen at times that developers write

    catch(e)
    {
    Throw(e);
    TheApplication().RaiseErrorText…..
    }
    I belive that in the above code Raise Error wont get fired..since throw e will cancel the opeartion there..
    Help me understanding it.

    Regards

  • Ahmed Fouad

    hi all,
    actually as siebel best practice it’s advised to cache business services
    and i did so

    but the problem that in our system there’s a BS to make Data Quality before update or insert

    invkoing this BS results in populating the Error Message Property in the workflow

    for Example in Data Quality
    if(name == “”)
    TheApplication().RaiseErrorText(“Error 100″);

    the Error Message property is then input for another business service to handle the error

    The Problem
    ===========
    due to caching the Error Message property is appended every time
    and error codes is accumlated

    the Question
    ============
    is there any way to clear it (without Remove Business Service Caching)

    see this link maybe it helps to understand the problem
    http://siebel.ittoolbox.com/groups/technical-functional/siebel-dev-l/error-code-in-raise-error-text-2310065?cv=expanded

  • Ahmed Fouad

    hi all,
    actually as siebel best practice it’s advised to cache business services
    and i did so

    but the problem that in our system there’s a BS to make Data Quality before update or insert

    invkoing this BS results in populating the Error Message Property in the workflow

    for Example in Data Quality
    if(name == “”)
    TheApplication().RaiseErrorText(“Error 100″);

    the Error Message property is then input for another business service to handle the error

    The Problem
    ===========
    due to caching the Error Message property is appended every time
    and error codes is accumlated

    the Question
    ============
    is there any way to clear it (without Remove Business Service Caching)

    see this link maybe it helps to understand the problem
    http://siebel.ittoolbox.com/groups/technical-functional/siebel-dev-l/error-code-in-raise-error-text-2310065?cv=expanded

  • Amateur

    Hi Neel,

    I would like to know, take a scenario if there are ten lines of code in TRY block and i know there would be an error on line 5 and i need to suppress the error and continue with my code execution. How should i encounter this scenario?

    Thx
    Amateur

    • http://intensedebate.com/people/neelmani neelmani

      If you know there is error on line 5 then why don't you fix it :)

      but there is no way in eScript to resume from where error occurred. You can suppress error but the control will go to finally clause or catch clause.

      This thing might be possible with a combination of eScript and workflow but I have never tried that.

      • Penky

        Hi Neel,
        what about a try/catch/finally inside another try/catch/finally?

        Let’s say I have a piece of code and inside this piece of code there are some lines which “might throw an error” … so could we pack these lines into a seperate try statement? If it fails, the “outside” try block will still continue, no?

  • Amateur

    Hi Neel,

    I would like to know, take a scenario if there are ten lines of code in TRY block and i know there would be an error on line 5 and i need to suppress the error and continue with my code execution. How should i encounter this scenario?

    Thx
    Amateur

    • http://intensedebate.com/people/neelmani neelmani

      If you know there is error on line 5 then why don't you fix it :)

      but there is no way in eScript to resume from where error occurred. You can suppress error but the control will go to finally clause or catch clause.

      This thing might be possible with a combination of eScript and workflow but I have never tried that.

  • Penky

    Hi Neel,
    thanks for this excellent series of posts. I have an addition to this one. I have tried to catch errors using the method described above (a switch statement in the catch block, catching the SBL-xxx codes) but it did not work. After a while I found that we can also use the e.errcode which seems to be individually for a certain error as well.
    So I tried something like this:

    catch(e) {

    if (e.errCode == ’22045′) { //same values for name, location…
    var accname = accBC.GetFieldValue(“Name”);
    accBC.SetFieldValue(“Name”, accname + ” *CHECK*”);
    accBC.WriteRecord();
    myfunction(); // run the function again
    }

    else if (e.errCode == ’22195′) //record has been modified since it was retrieved
    myfunction() // run the function again …

    else if (e.errCode == ’22709′) { //fill in all mandatory fields
    if (accBC.GetFieldValue(“Street Address”) == “”) {
    accBC.SetFieldValue(“Street Address”,”empty”);
    accBC.WriteRecord();
    myfunction()
    }
    else if (accBC.GetFieldValue(“Postal Code”) == “”) {
    accBC.SetFieldValue(“Postal Code”,”empty”);
    accBC.WriteRecord();
    myfunction()
    }
    else if (accBC.GetFieldValue(“City”) == “”) {
    accBC.SetFieldValue(“City”,”empty”);
    accBC.WriteRecord();
    myfunction()
    }

    }

    else
    WshShell.Popup(“This is e.errcode: ” + e.errCode + ” – This is e.toString: ” + e.toString());

    //throw e;

    } //end catch

  • Shiv

    Hi Neel,

    I am silent admirer of your posts. I am posting for the first time, please keep enlightening the Siebel community.

    Regarding this post, why not make the field Force Active on the Field level to get rid of this error!!!

    Regards,
    Shiv

    • Anonymous

      Hi Shiv,

      Thanks for the compliments. You are right we can make the field force active to avoid this error but there are two things I would like to say:
      1. the code in the above post is just to demonstrate an example and not to fix this particular type of error.
      2. Making field force active is not the solution of the this problem ideally we should be doing an activate field before doing a get field value which will eliminate these errors.

  • Scriptless Siebel
  • Product Configurator