How To invoke a Siebel Business Service

In this post I will elaborate how we can invoke a business service in various ways. But first just an overview of what business service is.

Business Service (BS): Is a place where you write to code to implement business rules and process.

We can also write the code at BusComp and Applet level but that makes our code and business logic to be

  • Distributed
  • Difficult to manage
  • Cannot be reused

Siebel Business service has a slight more overhead than the code at Applet or BusComp level but it helps us to make our code

  • Centralized
  • Easier to manage
  • Can be reused

 So general rule of thumb to select where to write the code is

If same business rules are applicable on more than one entity then we write a generalized code at BS level.

You can create business services in

Siebel Tools: Code change is SRF dependent.
Siebel Client: Code change is SRF independent.

You can read more on both kinds of business services in the following post.

We can invoke a business Service through

  1. Runtime Events
  2. eScript
  3. User Property
  • Runtime Events

To call a business service through runtime events

Enter the following information in the Action Set that you are creating

Business Service: Business Service Name
Business Service Method: Method Name
Business Service Context: “Input Argument”, “Value”

And based on the Event that you choose this business service will be invoked

  • eScript

You can use the following Code to invoke a business service from escript

var svc = TheApplication().GetService(“BS Name”);
var Input = TheApplication().NewPropertySet();
var Output = TheApplication().NewPropertySet();
Input.SetProperty(“Type”,this.GetFieldValue(“Status”)); // Input Agruments
svc.InvokeMethod(“BSMethod”, Input, Output);

  • User Property

You can use named method property to invoke a business service from BC but this method is rarely used as it including complex conditions in the User property might not be possible. But it can come quite handy if you just want to invoke BS based on simple conditions

Name: Named Method 1
Value: “New Record”, “INVOKESVC”, “BS Name”, “BS Method”, “‘Input Agrument’”, “Value”, “‘Input Argument 2’”, “Value”

To see details of this user property read the following post

This Post has been viewed : 80,512 Times


43 Responses to How To invoke a Siebel Business Service

  1. Hi ple give me more information about Business services i need step by step with example… It’s U have possible ple do help….

    Thanks
    Siva

  2. Hi ple give me more information about Business services i need step by step with example… It’s U have possible ple do help….

    Thanks
    Siva

    • Hi Neel,

      I am facing a typical situation using Run time event in my project. I have a Run time event based on Action BC, write record. In Action set, we have called a custom BS & passing the WF name (to extecute)as BS context.Since we have 2 places from where the activity record can be created – one from Activity screen & another from Service Request- Activity, we are observing that if we trigger the trnx from Action screen, run time is working as expected. However, if we are triggering the trnx from Service Request-Action, run time event is fired multiple time within few seconds.

      We are about to go in UAT in few days. Please suggest

      • Lovely,

        use instructions given in the following post to enable personalization log.
        http://siebelunleashed.com/siebel-personalization-log/
        This will help you to determine what exactly is causing runtime event to trigger or is that something else that is causing the issue

        It might be possible some script on a bc or applet might be causing write record event to trigger multiple times.
        Let me know what you find in logs and I might be able to help you out

  3. I am not sure what you mean by more information. If you can tell me what exactly you need, I might be able to help you out.

  4. Hi Neel can U tell What type of input and output arguments can take in Business services… in which input and out put arguments are avaliable..ple help me

  5. Hi Neel can U tell What type of input and output arguments can take in Business services… in which input and out put arguments are avaliable..ple help me

  6. you can only pass propertyset in business service.

    if you want to pass any other value then you have to set it as property.

    Will soon write a post explaining the process of calling BS from script

  7. you can only pass propertyset in business service.

    if you want to pass any other value then you have to set it as property.

    Will soon write a post explaining the process of calling BS from script

  8. Believe we can even use RCR to invoke a Business service.

    However Neel,dint understood,what did you mean by enitiy mentioned in your thumb rule which seems to be an criteria to implement a business service. Plz elaborate on this.

    and if a person,would like to start off from the basic of scripts,what would you advice.

    Thanks in advance
    Soj

  9. Believe we can even use RCR to invoke a Business service.

    However Neel,dint understood,what did you mean by enitiy mentioned in your thumb rule which seems to be an criteria to implement a business service. Plz elaborate on this.

    and if a person,would like to start off from the basic of scripts,what would you advice.

    Thanks in advance
    Soj

  10. Hi,
    I have seen example of invoking a BS, but cant seem to find any example which gives step by step procedure to write a small BS, and then invoke it from eScript.

    i have a BS to sum two numbers, how do i access the two arguments inside the BS which are passed to it ?

  11. Hi,
    I have seen example of invoking a BS, but cant seem to find any example which gives step by step procedure to write a small BS, and then invoke it from eScript.

    i have a BS to sum two numbers, how do i access the two arguments inside the BS which are passed to it ?

  12. How to invoke a business service with a method which doesnt have any arguments(thru script)?

    for eg:

    var svc = TheApplication().GetService(”BS Name”);
    var Input = TheApplication().NewPropertySet();
    var Output = TheApplication().NewPropertySet();
    Input.SetProperty(”Type”,this.GetFieldValue(”Status”)); // Input Agruments
    svc.InvokeMethod(”BSMethod”, Input, Output);

    here we are passing input and out put args rt? what if if u dont have any arguments in the BS method?

  13. How to invoke a business service with a method which doesnt have any arguments(thru script)?

    for eg:

    var svc = TheApplication().GetService(”BS Name”);
    var Input = TheApplication().NewPropertySet();
    var Output = TheApplication().NewPropertySet();
    Input.SetProperty(”Type”,this.GetFieldValue(”Status”)); // Input Agruments
    svc.InvokeMethod(”BSMethod”, Input, Output);

    here we are passing input and out put args rt? what if if u dont have any arguments in the BS method?

  14. you have to pass these propertyset.. this is the syntax to call to the BS in siebel but it doesn’t mean that you are passing input arguments.

    taking your example

    var svc = TheApplication().GetService(”BS Name”);
    var Input = TheApplication().NewPropertySet();
    var Output = TheApplication().NewPropertySet();
    //Input.SetProperty(”Type”,this.GetFieldValue(”Status”)); // Input Agruments
    svc.InvokeMethod(”BSMethod”, Input, Output);

    commenting the setproperty line will result in calling business service without any input arguments.

  15. you have to pass these propertyset.. this is the syntax to call to the BS in siebel but it doesn’t mean that you are passing input arguments.

    taking your example

    var svc = TheApplication().GetService(”BS Name”);
    var Input = TheApplication().NewPropertySet();
    var Output = TheApplication().NewPropertySet();
    //Input.SetProperty(”Type”,this.GetFieldValue(”Status”)); // Input Agruments
    svc.InvokeMethod(”BSMethod”, Input, Output);

    commenting the setproperty line will result in calling business service without any input arguments.

  16. Actually you do not need to pass a property set if you are using Script Assist in 8.0

    var svc = TheApplication().GetService(”BS Name”);
    var status = svc.(“Type”, this.GetFieldValue(”Status”));

    By typing svc. will give you a dropdown of all the functions available in the BusSrv you are calling.

  17. Actually you do not need to pass a property set if you are using Script Assist in 8.0

    var svc = TheApplication().GetService(”BS Name”);
    var status = svc.(“Type”, this.GetFieldValue(”Status”));

    By typing svc. will give you a dropdown of all the functions available in the BusSrv you are calling.

  18. Hi,
    Please look into this once.
    I have written a business service and i m calling that in contact list applet for that i have written this code in Applet.

    function WebApplet_PreInvokeMethod (MethodName)
    {
    if(MethodName == “InactivateContact”)
    {

    var K_BCContact = this.BusComp();
    var Id = this.BusComp().GetFieldValue(“Id”);
    var WF = TheApplication().GetService(“NN EQ1Y1”);
    var WFIn = TheApplication().NewPropertySet();
    var WFOut = TheApplication().NewPropertySet();
    WFIn.SetProperty(“Object Id”,Id);
    WF.InvokeMethod(“Inactivate”,WFIn,WFOut);
    return (CancelOperation);
    }

    return (ContinueOperation);
    }

    this code for Business service.in this If i use “ActiveBusObject()” it is woking fine,
    If i use “GetBusObject(“Contact”);” it is saying:- this operation is not allowed when there is no records pls execute a query or create a new record to do this operation.(SBL-DAT-00215)
    here my method name Inactive and Argment for that is Object Id,

    function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
    {
    if(MethodName == “Inactivate”)
    {
    var msg=COMCreateObject(“WScript.shell”);
    var A = Inputs.GetProperty(“Object Id”);
    msg.PopUp(A);
    var K_BOContact = TheApplication().GetBusObject(“Contact”);
    var K_BCContact = K_BOContact.GetBusComp(“Contact”);
    K_BCContact.ActivateField(“Id”);
    K_BCContact.ActivateField(“Type”);
    K_BCContact.ActivateField(“Status”);
    K_BCContact.ClearToQuery();
    K_BCContact.SetSearchSpec(“Id”,A);
    K_BCContact.ExecuteQuery();

    var ktype = K_BCContact.GetFieldValue(“Type”);
    var kstatus = K_BCContact.GetFieldValue(“Status”);
    if((K_BCContact.GetFieldValue(“Type”) == “Premium”) &&(K_BCContact.GetFieldValue(“Status”) != “Inactive”))
    {
    TheApplication().RaiseErrorText(“You can not Inactivate a premium Contact”);
    return (CancelOperation);
    }
    else if((K_BCContact.GetFieldValue(“Type”) == “Premium”) && (K_BCContact.GetFieldValue(“Status”) == “Inactive”))
    {
    var fname = K_BCContact.GetFieldValue(“First Name”);
    var lname = K_BCContact.GetFieldValue(“Last Name”);
    var K_BOAsgn = TheApplication().GetBusObject(“Asgn Error”);
    var K_BCAsgn = K_BOAsgn.GetBusComp(“Asgn Error Log”);
    K_BCAsgn.ExecuteQuery(ForwardOnly);
    var time = K_BCAsgn.GetFieldValue(“Updated”);
    K_BCAsgn.NewRecord(NewAfter);
    K_BCAsgn.SetFieldValue(“Object Type”,”BUsiness Service”);
    K_BCAsgn.SetFieldValue(“Object Name”,”NN EQ1Y1″);
    K_BCAsgn.SetFieldValue(“Entity Instance”,lname+”&”+fname);
    K_BCAsgn.SetFieldValue(“Error Massage”,”Selected Record is alredy inavtive”);
    K_BCAsgn.SetFieldValue(“Time Stamp”,time);
    K_BCAsgn.WriteRecord();
    TheApplication().RaiseErrorText(fname+”,”+lname+”is Already Inactive”);
    return (CancelOperation);
    }
    else
    {
    var fname = K_BCContact.GetFieldValue(“First Name”);
    var lname = K_BCContact.GetFieldValue(“Last Name”);

    TheApplication().TraceOn(“c:\temp\Trace.txt”,”Allocation”,”All”);
    var buff1 = new Buffer(100 , true , true);
    TheApplication().Trace(“Buffer 1 value: “+fname+lname);
    TheApplication().TraceOff();
    K_BCContact.SetFieldValue(“Status”,”Inactive”);
    K_BCContact.WriteRecord();

    return (CancelOperation);
    }
    }

    return (ContinueOperation);
    }

    so please help me in this.

    Thanks
    Kiran.

  19. Hi,
    Please look into this once.
    I have written a business service and i m calling that in contact list applet for that i have written this code in Applet.

    function WebApplet_PreInvokeMethod (MethodName)
    {
    if(MethodName == “InactivateContact”)
    {

    var K_BCContact = this.BusComp();
    var Id = this.BusComp().GetFieldValue(“Id”);
    var WF = TheApplication().GetService(“NN EQ1Y1”);
    var WFIn = TheApplication().NewPropertySet();
    var WFOut = TheApplication().NewPropertySet();
    WFIn.SetProperty(“Object Id”,Id);
    WF.InvokeMethod(“Inactivate”,WFIn,WFOut);
    return (CancelOperation);
    }

    return (ContinueOperation);
    }

    this code for Business service.in this If i use “ActiveBusObject()” it is woking fine,
    If i use “GetBusObject(“Contact”);” it is saying:- this operation is not allowed when there is no records pls execute a query or create a new record to do this operation.(SBL-DAT-00215)
    here my method name Inactive and Argment for that is Object Id,

    function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
    {
    if(MethodName == “Inactivate”)
    {
    var msg=COMCreateObject(“WScript.shell”);
    var A = Inputs.GetProperty(“Object Id”);
    msg.PopUp(A);
    var K_BOContact = TheApplication().GetBusObject(“Contact”);
    var K_BCContact = K_BOContact.GetBusComp(“Contact”);
    K_BCContact.ActivateField(“Id”);
    K_BCContact.ActivateField(“Type”);
    K_BCContact.ActivateField(“Status”);
    K_BCContact.ClearToQuery();
    K_BCContact.SetSearchSpec(“Id”,A);
    K_BCContact.ExecuteQuery();

    var ktype = K_BCContact.GetFieldValue(“Type”);
    var kstatus = K_BCContact.GetFieldValue(“Status”);
    if((K_BCContact.GetFieldValue(“Type”) == “Premium”) &&(K_BCContact.GetFieldValue(“Status”) != “Inactive”))
    {
    TheApplication().RaiseErrorText(“You can not Inactivate a premium Contact”);
    return (CancelOperation);
    }
    else if((K_BCContact.GetFieldValue(“Type”) == “Premium”) && (K_BCContact.GetFieldValue(“Status”) == “Inactive”))
    {
    var fname = K_BCContact.GetFieldValue(“First Name”);
    var lname = K_BCContact.GetFieldValue(“Last Name”);
    var K_BOAsgn = TheApplication().GetBusObject(“Asgn Error”);
    var K_BCAsgn = K_BOAsgn.GetBusComp(“Asgn Error Log”);
    K_BCAsgn.ExecuteQuery(ForwardOnly);
    var time = K_BCAsgn.GetFieldValue(“Updated”);
    K_BCAsgn.NewRecord(NewAfter);
    K_BCAsgn.SetFieldValue(“Object Type”,”BUsiness Service”);
    K_BCAsgn.SetFieldValue(“Object Name”,”NN EQ1Y1″);
    K_BCAsgn.SetFieldValue(“Entity Instance”,lname+”&”+fname);
    K_BCAsgn.SetFieldValue(“Error Massage”,”Selected Record is alredy inavtive”);
    K_BCAsgn.SetFieldValue(“Time Stamp”,time);
    K_BCAsgn.WriteRecord();
    TheApplication().RaiseErrorText(fname+”,”+lname+”is Already Inactive”);
    return (CancelOperation);
    }
    else
    {
    var fname = K_BCContact.GetFieldValue(“First Name”);
    var lname = K_BCContact.GetFieldValue(“Last Name”);

    TheApplication().TraceOn(“c:\\temp\\Trace.txt”,”Allocation”,”All”);
    var buff1 = new Buffer(100 , true , true);
    TheApplication().Trace(“Buffer 1 value: “+fname+lname);
    TheApplication().TraceOff();
    K_BCContact.SetFieldValue(“Status”,”Inactive”);
    K_BCContact.WriteRecord();

    return (CancelOperation);
    }
    }

    return (ContinueOperation);
    }

    so please help me in this.

    Thanks
    Kiran.

  20. Hi

    I’ve just read in the bookshelf (developer’s reference), that is possible to invoke a business service from a calculated field by InvokeServiceMethod function.

  21. Hi

    I’ve just read in the bookshelf (developer’s reference), that is possible to invoke a business service from a calculated field by InvokeServiceMethod function.

  22. Hi,
    Need some help.I want to invoke a BS through Runtime event. In the BS i want to get the row id of the record on which the RunTime event fired.
    How do we get this.
    Thanks

  23. Hi,

    can you post the syntax of invoking buscomp method from a business service?
    i believe we can use InvokeMethod() function, but i dunno how to pass the arguments to it.

    • yes you can … your BS pre invoke method will be called and executed but method name is the required field while simulation so you will have to give some dummy name in that….

      Siebel will look for that method name in the BS Pre Invoke code….

  24. this is kumar
    please can uyou guide me how to connecte to cyber source eservice inorder to calulation of tax in e sales

  25. Hello kind siebel users!

    Have any of you experienced the following before? : We analyzed some siebel scripts and some of it calls a service’s method, but in the method browser, all of them missing. The srf and the used local siebel database is correct and up to date. I am totally not a siebel expert but got some minor tasks on it so I have to used to it…

    • Yes, methods defining is optional siebel. You can just capture them in Business service preinvoke method. for example

      if(MethodName == “XXX”)
      do something

      if(MethodName == “YYY”)
      do something

      It means that BS supports two methods.. but you might not see any method defined in Method object of that BS…

      I hope it clears up your doubt

Leave a Reply

Contribute