Monday, July 19, 2010

Getting Started with SIFs

Having downloaded the source files this should help get things started:

1. Import the business service and the workflow process.

2. Add the following line to the config file in the appropriate place (in the [SWE] section)

ClientBusinessServiceXX  = "MFramework"

3. Check in and Deploy the WF Process "MFramework Service Wrapper WF" (if you want to use the asynch business service calling feature).

4. Add the following to the server script declarations section of the application you are using:

var oBS:Service = this.GetService("MFramework");
oBS.InvokeMethod ("BuildFramework", NewPropertySet(), NewPropertySet());

5. Add the following as a new method in the server script of the application you are using:


function FrameworkHandle()
{
    return this.GetService("MFramework").frameworkHandle();
}

This acts as a wrapper for BCs, BSs etc to get a reference to the Framework object.

6. Add the following to the browser script declarations section of the application you are using:

setTimeout("BuildFramework()", 1000);

7. Add the following as a new method in the browser script of the application you are using:


function BuildFramework()
{
    var bsUi = theApplication().GetService("MFramework");
    bsUi.InvokeMethod("BuildBsFramework",NewPropertySet());
};

8. Compile and generate browser scripts.

Run the application.

To test we'll run some of the browser side functionality (which in turn runs the server side, so is a good way to smoke test)... so when the application is running copy and paste the following into the address bar:

javascript:alert(top.oFramework.BusComp.getRecord("Employee.Employee", "0-1", ["Full Name"])["Full Name"]);
//

Hopefully you'll get an alert with "SADMIN SADMIN" here, if so, great, it works!

Some more tests:

javascript:alert(top.oFramework.BusComp.getRecord("Employee.Employee", "0-1", ["Full Name"]).Full_Name);
//

Same result as above, just accessing the value in a subtly different way.

javascript:alert(top.oFramework.Lov.getDescription("LOV_TYPE","LOV_TYPE"));
//

Here you should get a description of the LOV_TYPE lov.

javascript:alert(top.oFramework.BusComp.getRecord("Employee.Employee", "0-1","").Created);
//

So that should give the Date of when the SADMIN Employee record was created.

javascript:alert(top.oFramework.BusComp.getRecord("Employee.Employee", "0-1","").Created.toDb());
//

Same as last test but displays in DD/MM/YYYY format. This makes use of two features of framework - new methods added to JS datatypes, and optional typing of fields in the BusComp.getRecord() method.

So hopefully that all works, let me know if not and I'll try and figure out why.

For info., I use 7.7 and the ST engine - I did have strong typing in the code, which I have removed to allow this work in the T engine, but there may be some  other problems with the way I use the JS objects, so let me know if you've any issues or thoughts.

And let me know if it works too, of course!

Matt

Framework SIFs

As promised here are some SIFs that should hopefully make getting this running a little bit easier, or at the very least make the code a little easier to follow.


Source Code


Contained in the .zip file above are a few files, which I'll briefly run through:


1. MFramework.sif


This is a SIF file of the business service that contains both the server side (eScript) elements of the Framework, and the corresponding Browser Script side. This business service is contained in a project called "MFramework".


2. MFramework_BS.sif


This is a SIF of just the business service, without containing project, if you want to import into a different project.


3. MFramework Service Wrapper WF.xml


This is a workflow process used by the asynch business service calling. As it currently is, this is contained in the project called MFramework.


4. MFramework_bs.js


If you'd prefer just to view the code in your favorite editor this file is the entire browser script side of the business service...


5. MFramework_ss.js


... while this is the server eScript of the business service.


I'll create a further post to give a quick "how to" list to get started with this shortly...


Matt

Saturday, July 10, 2010

Coming soon...

Folks, just thought I'd post a quick note about some items in the pipeline... I'm on holidays at the moment, so haven't been near a computer in a while.


Puli posted an interesting comment on the lack of security on the browser script side - remember this passes a call down to the server side, where an eval is used. Well, with some playing around I got some unauthorised code to run. I'm not sure what mischief could be caused by this, but this is an unexpected problem - I've some examples of this in action, and a (hopefully) straightforward fix.

The Framework uses a technique described in Oracle Doc Id 579955.1 - which basically shows how to directly run methods on a cached business service (avoiding the dreaded InvokeMethod and property sets!). It has been suggested to me that caching business services can cause problems in later versions of Siebel. (I'm using Linux at the moment, and the Oracle support site seems to take exception to this for some reason and won't allow me in so I can't check!) - I'll post an alternative way to make the Framework work without the BS caching (and no visible difference to the callers of the Framework).

Finally, the SIFs - a good few comments saying the code is great, which is nice, but not necessarily straightforward to cut and paste, and expect to get working. I have some SIFs nearly ready to go, I just need to remove some specific code from a few places... I do have these, but not actually tested them yet, so once tested will post up.

Matt