Displaying an Alternate Part
You can display an alternate part from a third-party system in PTC Arbortext Content Delivery.
Follow these steps to display an alternate part in PTC Arbortext Content Delivery:
1. Open the pricingService.js file located in the directory <HOME>/SW/SW/Applications/Windchill.ear/codebase.war/delivery/app/services.
2. Locate the pricingService.updatePriceInItems function in the pricingService.js file.
3. In the pricingService.updatePriceInItems function, add a new function to add the custom metadata attributes inside the part item.
4. Open the priceAndAvailability.html file located in the directory <HOME>/SW/SW/Applications/Windchill.ear/codebase.war/delivery/app/directives/price.
5. Locate the <div class="availabilityIdClass"></div> tag in the priceAndAvailability.html file.
6. Add the code to show newly added attributes for the alternate part in the part item description after the <div class="availabilityIdClass"></div> tag.
7. Open the priceAndAvailabilityDirective.js file located in the directory <HOME>/SW/SW/Applications/Windchill.ear/codebase.war/delivery/app/directives/price and perform the following edits:
a. Declare the variables for the alternate part in the definition function of the priceAndAvailabilityDirective.js file.
b. Locate the availabilityElement.text element and add the code to get the attribute value from a part item and assign the value to the alternate part number and alternate part location attributes.
8. Run the following command from a Windchill shell to minimize the client: <ANT_HOME>/bin/ant -f <HOME>/SW/SW/Applications/Windchill.ear/codebase.war/delivery/minimize.xml.
The alternate part details are displayed on the part information pages in PTC Arbortext Content Delivery.
In this example, you add an alternate part and its location details obtained from a third-party system for all part items in PTC Arbortext Content Delivery.
Follow these steps to add an alternate part from a third-party system for all part items in PTC Arbortext Content Delivery:
1. Open the pricingService.js file located in the directory <HOME>/SW/SW/Applications/Windchill.ear/codebase.war/delivery/app/services.
2. Locate the pricingService.updatePriceInItems function in the pricingService.js file.
3. In the pricingService.updatePriceInItems function, add the following updateAlternatePart function to add the custom metadata attributes inside the part item:
pricingService.updatePriceInItems = function (itemsWithPricing, itemsWithout) {
var i;
for (i = 0; i < itemsWithPricing.length; i++) {
var item = itemsWithPricing[i];
var idx = utils.findItemIndexById(item, itemsWithout);
if (idx >= 0) {
var gridItem = itemsWithout[idx];
pricingService.updatePriceInItem(gridItem, item.attributes);
pricingService.updateAlternatePart(gridItem, item.customMetadata);
}
}
};
pricingService.updateAlternatePart = function (item, customMetadata)
{ 131
/* below code is written just for reference. Here, all the entries from actual json
customMetadata should be copied to item customMetadata*/
item.customMetadata.Partnumber = customMetadata.Partnumber;
item.customMetadata.location = customMetadata.location;
};
4. Open the priceAndAvailability.html file located in the directory <HOME>/SW/SW/Applications/Windchill.ear/codebase.war/delivery/app/directives/price.
5. Locate the <div class="availabilityIdClass"></div> tag in the priceAndAvailability.html file
6. Add the following code to show the newly added attributes for the alternate part in the part item description after the <div class="availabilityIdClass"></div> tag:
Alternate Part:<div class="alternatePartNumber"> </div>
Location:<div class="alternatePartLocation"> </div>
7. Open the priceAndAvailabilityDirective.js file located in the directory <HOME>/SW/SW/Applications/Windchill.ear/codebase.war/delivery/app/directives/price and perform the following edits:
a. Declare the following variables for the alternate part in the definition function of the priceAndAvailabilityDirective.js file:
var alternatePartNoElement = element.find('.alternatePartNumber');
var alternatePartLocationElement = element.find('.alternatePartLocation');
b. Locate the availabilityElement.text element and add the following code to get the attribute value from a part item and assign the value to the alternate part number and alternate part location attributes:
var alternatePartNo = $parse('item.customMetadata.
Partnumber.value')(scope);
alternatePartNoElement
.text(alternatePartNo);

var alternatePartLocation = $parse('item.customMetadata
.location.value')(scope);
alternatePartLocationElement
.text(alternatePartLocation);
8. Run the following command from a Windchill shell to minimize the client: <ANT_HOME>/bin/ant -f <HOME>/SW/SW/Applications/Windchill.ear/codebase.war/delivery/minimize.xml.
The alternate part details are displayed on the following part information page: