Siebel Interactive Selling Transact Server Interface Reference > The Shopping Cart >

Accessing Part (Subitem) Data

Just as a quote consists of multiple line items, a line item consists of multiple parts. And, using a method similar to the one in which we iterate through the line items in the quote, we must iterate through the parts for the line item. Since the parts belong to the current line item being accessed in the line item loop, we iterate through them within the line item loop, producing a nested loop. This may sound complicated, but it is actually fairly simple. The code sample in the above section simply expands to the one shown below:

while ( bean.hasMoreLineItems() )
<!-- Line Item specific HTML goes here -->
while ( bean.hasMoreParts() )
<!-- Part specific HTML goes here -->

From within the part section of the cart, you can make calls into the ShoppingCartBean API to get specific information about that part to display on the shopping cart interface. Examples of part information that are provided through the API include description, price, and part number.

Feature table data is also available through the ShoppingCartBean API. It is accessed using a methodology similar to the retrieval of custom-defined header fields. You can use the function getPartField and pass in the name of the column, and the function will return the corresponding value. An example is shown below.

<%= bean.getPartField("DESC") %>

You can also create part-level custom fields using this function. In other words, if the field name you provide to the function is not one that is stored for that part, it will create it for you and any data the user may enter for that field (if it is editable) will be stored with the cart. Any changes that are made to part level data through the shopping cart will not be reflected on linkback. The data used for linkback is stored separately and is not editable through the shopping cart, in order to guarantee configuration validity on linkback.

Since feature tables differ across pagesets and there is only a single cart interface to display the myriad pagesets, the ShoppingCartBean includes an API function which returns all matching field names in the feature table data for the current part.

For example, if you had a "PRM" column in a feature table in all of your pagesets, but the feature tables were all named differently, you would use this function to access the column so that you would not need to specify the table name ("TABLE.PRM").

The function is called getMatchingPartFields. Since this function returns all matching field/value pairs, more than one value may be returned. To allow for this possibility, the function returns an array of key value pair objects. The objects have a key field and a value field which are both Strings. You access the array, and the fields in the objects, exactly as you would in JavaScript.

An example is shown below. For a more detailed example, see the getMatchingPartFields entry in getMatchingPartFields.

<% KeyValuePair [] matches = bean.getMatchingPartFields("PRM");
if (matches.length > 0) {
<td>PRM: <%=matches[0].value %> </td>
<% } %>

The first statement in the example declares an array of KeyValuePair objects as the return value for the getMatchingPartFields function call. This array is populated by any and all fields and values which have "PRM" as part of their field name. The next statement looks to see if any matching fields were returned for this part. "matches.length" returns the number of entries in the array and if it is greater than zero, then there is at least one matching field. Since we know that there are no other fields in our data model containing "PRM," we can assume that the first array record has the value we are interested in, and we can print it into a table cell labeled "PRM: ". That's what the next lines do. First, we close off the code block, since we want to print something out to the screen. Then we make our HTML table cell with the label we want and print the value of the first array record using "<%= matches[0].value %>". The "matches[0]" specifies the first KeyValuePair object in the array, and the ".value" specifies to access the value field (".key" would give us the field name).

 Siebel Interactive Selling Transact Server Interface Reference 
 Published: 18 April 2003