Pricing Administration Guide > Script-Based Pricing Factors > The Process of Implementing Script-Based Pricing Factors >

Planning and Writing the Script


As mentioned earlier, this chapter will not include specific instructions for writing the script. For more information about Siebel's scripting languages, see Siebel Tools Online Help. Also, look at the sample script at the end of this chapter.

This section will give you basic information about the interaction between the script and the pricing engine.

Passing Information to the Script

For information to be passed to a script, the following conditions must all be met:

You should verify that these four conditions are met for every item in the script.

Within the script, you get information by referencing the data about user properties that you created for this script. You can reference this data by using a key name starting with Var, to retrieve the attribute values that you entered when you created the business service. For example, if you entered the values shown in Table 35 when you created the business service, you can use those values in the script by writing the following code:

var QuoteName = Inputs.GetProperty ("Var 1");

var QuoteCurCode= Inputs.GetProperty ("Var 2");

var ProductName= Inputs.GetProperty ("Var 3");

var Color = Inputs.GetProperty ("Var 4");

The Var # syntax is used to represent variables, regardless of whether this item was in the user properties as a field or a parameter.

To avoid problems, observe the following cautions:

Creating the Pricing Logic

Write the script to implement whatever business service functionality is required to accomplish your business process. The logic should determine:

Getting Results Out of the Script

To get the results from the script into the Net Price field and the Pricing Comments field of a line item, you set the properties in the Outputs properties set that are shown in Table 36.

Table 36.  Output Properties Used to Get Results Out of the Script
Property
Description
Script Applied
If the value is set to True, the pricing adjustment is considered and the flow takes the Y edge. If the value is set to False, any pricing adjustments are disregarded and the flow takes the N edge. The default value is False.
Current Price
The price result of the script factor. This is how you pass back the results of the script. This value is used in the calculation to determine what is entered in the Net Price field.
Reason
This string explains to the user what adjustments were made and why. This field is concatenated for all factors and entered in the Pricing Comments field.

Scripts for Multiple Business Objects

It is possible to write scripts that mix business objects, as long as they do not mix customizable products with other objects. For example, you can write a single script and have it work for Quotes, Orders, and wherever else scripting is used.

To do this, you must specify user properties for each field that data comes from. For example, instead of the user properties shown in Table 35, which all refer to one business object, you could specify user properties similar to those shown in Table 37.

Table 37.  Properties Used to Pass Information to the Script
Name
Value
Field 1
Quote.Account Name
Field 2
Order Entry - Orders.Account Name

Whenever the script runs, one of these variables will be null and the other will have a value, depending on which business object the pricing is being invoked from. The logic of the script would have to take this into account and condition the logic to perform operations based only on those parameters that were actually passed.

CAUTION:  Do not create scripts that mix customizable products with any other objects. If customizable products and simple products need the same pricing, write two physically separate business services and invoke these services with separate pricing factors.

Legacy Syntax

Do not use the following legacy syntax in scripts.

If you see a user property named __BusComp Name __ this is a script with legacy syntax from version 6.x. This syntax will continue to work for version 7.x for simple products only if you carefully followed the recommended algorithm in the 6.x Bookshelf.

CAUTION:  This legacy syntax will not work for customizable products in version 7.x. If you use a script with this syntax, and a customizable product is present, Siebel ePricer will return an incorrect price.

Troubleshooting and Debugging the Script

If the script does not work properly, the problem may be caused by one of these common errors:

To help with debugging, you should implement error trapping and logging within the script. If you do not, any errors in the script will result in the script failing, applying no adjustment, with no indication of why this has happened.

Another debugging technique is to use the script debugging functionality of Siebel Tools.

An important debugging technique is to use the property set dumping function shown below. This function writes the full inputs and outputs property sets to a text file so you can see exactly what information is actually going in and out of your script. It creates a log file called PricingScriptFactor.log in the log directory for the application you are running.

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)

{

PropertySetToFile(Inputs, "..\\log\\PricingScriptFactor.log", "Property Set with Variable Map In");

// Pricing functionality goes here

PropertySetToFile(Outputs, "..\\log\\PricingScriptFactor.log", "Property Set with Variable Map Out");

return (CancelOperation);

}

function PropertySetToFile (PropSet, fileName, title)

{

var file = Clib.fopen(fileName, "at");

LogData(("\n---------------------------------------------------"), file);

LogData(("Start Process " + Clib.asctime(Clib.gmtime(Clib.time()))), file);

LogData(title, file);

LogData("PROVIDED PROPERTY SET", file);

WritePropertySet(PropSet, file, 0);

Clib.fclose(file);

return (CancelOperation);

}

function WritePropertySet(PropSet, file, Level)

{

if ((Level == "") || (typeof(Level) == "undefined")){

Level = 0;

}

var indent = "";

for (var x = 0; x < Level; x++){

indent += "\t";

}

var psType = PropSet.GetType();

var psValue = PropSet.GetValue();

LogData((indent + "Type: " + psType + " Value: " + psValue), file);

var propName = PropSet.GetFirstProperty();

while (propName != ""){

var propValue = PropSet.GetProperty(propName);

LogData((indent + propName + " = " + propValue), file);

propName = PropSet.GetNextProperty();

}

var children = PropSet.GetChildCount();

for (var x = 0; x < children; x++){

LogData(( indent + "CHILD PROPERTY SET " + x), file);

WritePropertySet(PropSet.GetChild(x), file, (Level + 1));

}

}

function LogData(DataString, file)

{

try {

Clib.fputs((DataString + "\n"), file);

Clib.fflush(file);

}

catch (e){

// no action

}

}


 Pricing Administration Guide 
 Published: 18 April 2003