Can You Open a Window Please?

advertisement
Can You Open a Window Please?
The following is upon request from fellow blogger Neel whom we
have to be ever grateful for his inspirational siebel
unleashed blog.
Neel asked me to discuss how to open a browser window from a
browser business service in Siebel CRM and I agreed. Now this
will raise some eyebrows as most of you know what I think
about browser scripting (and scripting in general) in Siebel
When I thought over Neel’s question what first came to my mind
were all the administrative and declarative alternatives like
Data Validation Manager, Unified Messaging Framework or the
Stop step in workflow processes. But I quickly discarded them
because I wanted to help Neel with his specific request.
So I dug out a little gem from the good old Siebel days in the
form of a practice lab from the inaugural version of the
Siebel Scripting Workshop.
The scenario for one of the labs of that workshop was the
following:
Users should be able to select “About Creator” from the Help
menu and a pop-up will be displayed with rich information
about the user who created the record. So it was the idea of
putting the well-known “About Record” a bit on steroids
The lab code didn’t actually open a popup window. We used a
mere theApplication().SWEAlert() to accomplish the display.
However, I imported the old code from the workshop and
modified to use window.open() and it worked like a charm as
you can see here:
The screenshot shows the new browser window displaying a
collection of fields from the user who created the selected
record.
As many of the following is basic Siebel configuration
(explained elsewhere in greater detail) and the scripting is
also pretty basic, I am going to lay out the steps for this
configuration in a rough fashion (it’s Summer, hey).
1. Create a Message object
While this is not really necessary for a quick prototype, I
have become really fond of showcasing the benefits of
translatable strings. To get a least some decent HTML in the
popup window, I created a custom Message Category with a
Message which holds the following text:
Full Name: %1<br>
Position: %2<br>
Phone #: %3<br>
Email: %4<br>
Fax #: %5<br>
Note the <br> tag at the end of each line. Messages use %1 etc
as placeholders.
2. Write the server-side business service
The general idea of the example is to get some fields of the
User business component. To accomplish this, I wrote a
business service server method (in eScript) which does the
following:
1. Retrieve the name of the current business component from
the input property set (passed by the browser BS).
2. Use ActiveBusinessObject() to instantiate the current
BC.
3. Get the creator’s ROW_ID for the active record.
4. Query the User business component with the creator’s
ROW_ID and get the desired field values.
5. Use the LookupMessage() function to replace the message
placeholders with the (formatted) field values,
constructing the message text for display.
6. Write the message text to the output property set,
passing it to the invoking browser BS.
3. Register the server-side business service as an application
client service
This is easily forgotten, so here is a short reminder:
Don’t forget to add a new Application User Property (to
whatever application you’re using) and add it to the sequence
of existing ClientBusinessServiceN properties. The value is
the name of the server-side business service (AAA Get User
Info in the screenshot) to which you allow external access
(e.g. from a browser script).
4. Write the browser-side business service
The general idea of a browser side business service is that
you can easily invoke it from anywhere (e.g. from a menu item)
and still have access to all the nifty features of browser
scripting.
Here is what my browser business service method does:
1. Instantiate the server-side business service.
2. Get the name of the active business component (that is,
the BC behind the active applet).
3. Construct the input property set for the server-side BS.
4. Invoke the server-side BS.
5. Display the message text passed from the server-side BS.
Here is the actual browser script code which I used to open a
new browser window and display the text:
//open a new window without URL
AAAWindow = window.open(“”,”AAAWindow”,”height=400,width=400″);
//ensure new window is in front
AAAWindow.focus();
//write the HTML header
AAAWindow.document.write(“<html><head><title>Creator
Information</title></head>”);
//write the HTML body including the message from the server BS
AAAWindow.document.write(“<body><h1>Creator
Information</h1><br>”
+
oPS.GetProperty(“message”));
//be a good boy and complete the HTML document
AAAWindow.document.write(“</body></html>”);
Of course, the above is just prototype code with lots of
“dont’s” in it but it should just convey the message that you
can open a browser window (using the window.open() function)
and
then
modify
the
window
content
with
the
window.document.write() function.
5. Create a Command to invoke the browser business service
Using Command objects to invoke business service method
invocations should be common sense. Once you have the command,
you can associate it to any application or applet menu item or
toolbar item. The basic properties for my new command were:
Business Service: Name of the browser business service
Display Name: Meaningful display name
Method: Name of the BS method to invoke
Target: Browser (this is important)
6. Associate the Command with a menu item
For the sake of demo, I added a new application menu item
labelled About Creator which invokes my new command.
Summary
When used purposefully, browser based business services can
help you close the gap between the user and the server such as
discussed in the above scenario.
have a nice day
@lex
Download