What is the use of return(CancelOperation)?

return(CancelOperation) statement is used to send the control back to Siebel or in other words to stop the normal flow of execution of script of a particular event.

This statement is mandatory if we are defining a custom method. For example:

 I create a button and give the method name as “CustomMethod”. Now, in BusComp PreInvoke event I write the following script

if(MethodName == “CustomMethod”)
{
My Script
}

If I don’t write the statement return(CancelOperation) at the end then I am going to get error saying: method “CustomMethod” is not supported by BusComp”

So, the correct and complete script when handling a custom method will be

if(MethodName == “CustomMethod”)
{
My Script
return(CancelOperation);
}

Related Questions

neel tagged this post with: , Read 39 articles by
  • Godfrey

    Does it mean that CancelOperation will not execute any statements written after CancelOperation?

  • neel

    Yes, that is correct.

  • Godfrey

    In siebel book shelf, Siebel Object Interface Reference book – Chaper Interfaces Reference – Figure 13. It seems that only the underlying siebel code is not executed but all the other statements after the CancelOperation is executed.

    However, ContinueOperation processes the underlying siebel code and then processes the remaining statements of code.

    Please correct me if my understanding is wrong.

  • neel

    Hi Godfrey,

    CancelOperation is always used with return statement.

    let’s forget about CancelOperation for a second, whenever you write return statement in a function the control will go back to calling function.

    Now when we use statement return(CancelOperation) there is no way the code after return statement is going to execute. here CancelOperation or ContinueOperation are indicators to the calling function whether to go ahead with the execution of code of calling function.

    CancelOperation = abort don’t execute anything
    ContinueOperation = abort from this function but continue with the execution of rest of the flow.

    I hope this clears your doubt

  • MNR

    hii…Neel

    what u said is true…but what about bookshelf comment ?
    this question i faced in my recent interview…and i have no clue..

    plz help me out

  • Ameya Pise

    Hi Neel. Your statement “there is no way the code after return statement is going to execute” is incorrect. As per bookshelf “CancelOperation stops the execution of the underlying Siebel code associated with the event.

    However, if there is code in the same script following CancelOperation, that code runs regardless of the CancelOperation”