Siebel Advisor API Reference > Callout Point Functions for Siebel Advisor >
COP_BeforeDisplayPriceString
Usage
This allows you to manipulate the HTML string before it appears in the Pricing window. Whatever changes you make to the original string 's' must be returned by this function. In other words, the end of this function must contain a 'return s' or whatever variable was chosen to hold the HTML string. Syntax
COP_BeforeDisplayPriceString(PriceObj, s, cols, font, body, title, table, close)
|
|
PriceObj |
A hierarchical price object sent from the server. This object may contain child objects if available. |
s |
A string containing the entire HTML output for the pop-up window. This includes everything from <HTML> to </HTML> that gets assembled through the standard code or through the callout point. |
cols |
An array of strings that contain the data to be displayed, in the order in which they appear. |
font |
A string that controls the font display. <FONT> tag. |
body |
A string containing the attributes for the <BODY> tag, such as background color. |
title |
A string that will display in the pop-up window title area. <TITLE> tag. |
table |
A string that contains attributes for the <TABLE> tag. All data for the pricing window appears in a table. |
close |
A string that contains the text displayed in the optional Close Window link. |
Example
The following sample code uses COP_BeforeDisplayPriceString to replace the Close Window text with an image. function COP_BeforeDisplayPriceString(PriceObj, s, cols, font, body, title, table, close) {
return s.replace(/Close Window/,"<img src='"+GetUIPath()+"close.gif' border=0>");
}
The following sample code displays the child pricing objects in indented format. The default pricing display is just the parent object. Sample output:
ACME Sedan |
2001 ACME Sedan V8 |
$9,000 |
Automatic Transmission |
5-speed Automatic Trans |
$1000 |
Air Conditioning |
Automatic Air Conditioning |
$900 |
Stereo Upgrade |
8-Speaker Premium Sound |
$500 |
CD Changer |
Trunk-mounted CD Changer |
$500 |
The ACME Sedan is the parent object. The Automatic Transmission, Air Conditioning and Stereo Upgrade are children (and they are indented). The CD Changer is a child of the stereo upgrade so it is further indented. For more information on parent/child modeling, refer to the Referencing Other Siebel Data chapter in Siebel Advisor Administration Guide. The sample code, which should be placed at the end of custom/customCode.js: function COP_BeforeDisplayPriceString(PriceObj, s, cols, font, body, title, table, close) {
if (typeof PriceObj != "undefined" && PriceObj != null) {
var s = "<html><head><title>"+title+"</title></head><body "+body+">";
s += "<font "+font+">";
s += "<table "+table+">";
// display all rows of data.
s += DisplayRow(PriceObj, cols, font);
s += "</table>";
// only display the close link if it is defined and if in a window (not frame)
if (close != "" && dispFrame == false) s += "<br><br><a href='javascript:void(0)' onclick=self.close()>"+close+"</a>";
s += "</font>";
s += "</body></html>";
return s;
}
}
// DisplayRow displays the PriceObj data as specified in cols. The depth determines how far to indent the description.
// Recursively displays all of the children and grandchildren.
function DisplayRow(PriceObj, cols, font, depth) {
var s = ""; // return string
var length;
var indent = "";
if (depth == null) {depth = 0};
var children = PriceObj.GetChildren();
s += "<tr>";
if (cols.length>0) {
for (var i=0;i<cols.length;i++) {
if (typeof PriceObj.GetField(cols[i]) != "undefined") {
// indent only the first field
if (i==0 && depth > 0) {
for (var d=0;d<depth;d++) {
indent += " "
}
} else {
indent = "";
}
s += "<td><font "+font+">"+indent+PriceObj.GetField(cols[i]) +"</font></td>";
} else {
s += "<td> </td>";
}
}
}
s += "</tr>";
// check for children objects, if exist, display them.
length = children.length;
if (length > 0) {
for (var j=0;j<length;j++) {
s += DisplayRow(children[j],cols,font,++depth);
depth--;
}
}
return s;
}
|