3 Replies Latest reply on Oct 9, 2011 3:27 PM by KenK

    Scripting, plz help

      i need to create a button in a screen in BC 1, such that on clicking it, a new record is created in BC 2, but the reqired details for that new record should be taken from the form applet of BC 1. I need to write a script for this process on that button, can someone help
        • 1. Re: Scripting, plz help
          Here's my suggestion for the code. Note that you need to provide the names of your business component and business objects, which I have coded in capital letters. Once you get the button added to the applet, add a condition in the applet's PreInvokeMethod to trap the button's Method and add this code to that condition:
               var bc1 = this.BusComp();
               var bo2 = TheApplication().GetBusObject("BO2");//Replace BO2 with the name of the Business Object for BC 2
               var bc2 = bo2.GetBusComp("BC2");//Replace BC2 with the actual name of BC 2
               var sTempValue = "";
                    sTempValue = bc1.GetFieldValue("BC1_FIELD_NAME");//Replace BC1_FIELD_NAME with the appropriate field from BC1
                    SetFieldValue("BC2_FIELD_NAME", sTempValue);//Replace BC2_FIELD_NAME with the appropriate field from BC2
                    //Repeat the above 2 lines of code (and replace the Field Names as appropriate) for as many fields as you want
                         TheApplication().RaiseErrorText("WriteRecord() failed! Error: " + e.toString());
          See Siebel Bookshelf, Siebel Object Interfaces Reference, Section 4's Applet Events and Business Component Methods
          • 2. Re: Scripting, plz help
            If you have the same requirement every time and 'BC 2' is a child of 'BC 1', you can use 'Pre Default' values of 'Parent: xxx'.

            It's always worth investigating the declarative options (BC / Field properties, User Properties) before you take the eScript route - it's better for performance, maintenance and for upgrading.


            • 3. Re: Scripting, plz help
              You may also want to consider some non-scripting approaches to this. Such as using a runtime event for to capture the button, and then a workflow with Siebel EAI Adapter as one of the steps and datamap between the two BCs.
              This would allow you change the mapping and add to it over time without the need to recompile the SRFs.