Business Scenario
Task Flow
Exercise options
Task 1: Create a Custom Table for the Available Decals
Steps
Create a custom table for the available decals.
Use the following data:
ProductName | PartNumber | Description | Price | Cost |
---|
Eiffel Tower decal | ADD1 | Decal of the Eiffel Tower | 18 | 12 |
Chrysler Building decal | ADD2 | Decal of the Chrysler Building | 19 | 12 |
Taj Mahal decal | ADD3 | Decal of the Taj Mahal | 21 | 12 |
Pyramids decal | ADD4 | Decal of the Great Pyramids | 17 | 12 |
Sydney Opera decal | ADD5 | Decal of the Sydney Opera House | 20 | 12 |
Use Excel to create a file called AdditionalProducts.xlsx containing the information from the table above.
Navigate to Setup → Product Catalog → Custom Tables.
Choose Import New.
For Table Name, enter: AdditionalProducts.
Choose Choose File and select AdditionalProducts.xlsx.
Choose Save.
Task 2: Create a Simple Product to Add a Decal to the Quote
Steps
Add a new product.
Use the following data:
Field | Value |
---|
Name | Additional Product |
Display Type | Simple Product |
Product Type | Accessories |
Category | Hardware > Computer Systems |
Navigate to Setup → Product Catalog → Products.
Choose Add New Product.
On the Definition tab, enter the information provided in the table above.
Choose Save & Go Back.
Task 3: Create a Quote Table
Steps
Create a quote table.
Use the following data:
Field | Value |
---|
Table Label | Additional Products |
Table Name | Additional_Products |
Quote Tab to show this table on | Quotation |
Table Rank | 10 |
Navigate to Setup → Product Catalog → Products.
Choose Add New.
On the Define Table tab, enter the information provided in the table above.
Choose Add Permission.
Check Select All Statuses.
Choose Add.
Choose Save.
Task 4: Define the Quote Table Columns
Steps
Add a column.
Use the following data:
Field | Value |
---|
Column Label | Select Product |
Column Name | Select_Product |
Column Type | Boolean |
On the Define Columns tab of the Additional Products quote table, choose Add Column.
Enter the information provided in the table above.
Choose Set Permissions.
Check Select All Permission Groups.
Choose Save.
Add the following columns.
Use the following data:
Column Label | Column Name | Column Type | Permissions |
---|
Name | Name | String | read-only |
Part Number | Part_Number | String | read-only |
Description | Description | String | read-only |
Price | Price | Decimal | read-only |
Cost | Cost | Decimal | read-only |
Repeat the steps described above to add the following columns (permissions default to read-only):
Choose Save, when all columns are added.
Task 5: Create a Script to Load the Quote Table from the Custom Table
Steps
Create a script to load the quote table from the custom table.
Use the following data:
Field | Value |
---|
Action Name | Load quote table from custom table |
On the Actions tab of the Additional Products quote table, choose Add Custom Action.
For Action Name, enter: Load quote table from custom table.
Under Script, build a script to populate the quote table from the AdditionalProducts custom table.
1234567891011
customTable = SqlHelper.GetList("SELECT * from AdditionalProducts")
quoteTable = context.Quote.QuoteTables['Additional_Products']
quoteTable.Rows.Clear()
for customRow in customTable:
newRow = quoteTable.AddNewRow()
newRow['Name'] = customRow.ProductName
newRow['Part_Number'] = customRow.PartNumber
newRow['Description'] = customRow.Description
newRow['Price'] = customRow.Price
newRow['Cost'] = customRow.Cost
Choose Save.
On the row for this action, choose Permissions.
Check Select All Permission Groups.
Choose Save.
Task 6: Create the Add Product(s) Script
Steps
Create the Add Product(s) script.
On the Actions tab of the Additional Products quote table, choose Add Custom Action.
For Action Name, enter: Add product(s).
Under Script, build a script to populate the quote table from the AdditionalProducts custom table.
123456789101112
quoteTable = context.Quote.QuoteTables['Additional_Products']
for quoteRow in quoteTable.Rows:
if quoteRow['Select_Product']:
newItem= quoteRow['Part_Number']
addedItem = context.Quote.AddItem('Additional_Product_cpq',1)
for item in context.Quote.GetAllItems():
if not item.PartNumber:
item.PartNumber = str(quoteRow['Part_Number'])
item.Description = str(quoteRow['Description'])
item.ExtendedAmount = quoteRow['Price']
Choose Save.
On the row for this action, choose Permissions.
Check Select All Permission Groups.
Choose Save.
Back on the Actions tab, choose Save.
Task 7: Deactivate Default Actions
Steps
Deactivate default actions.
Before you leave the Actions tab, unselect the Active checkbox for the following actions:
- Add row
- Delete row
- Copy row
Task 8: Test the Quote Table
Steps
Test the quote table.
Exit Setup and create a new quote.
Add one or more products to the quote.
Choose Current Quote then choose View Quote.
Delete all existing items added to quote.
On the Quotation tab, under Custom Fields, choose the Load quote table from custom table button.
Select one or more of the listed decals.
Choose the Add product(s) button.
Verify that the selected products were added to the quote under Products.
Note
The decals will be listed as Additional Product under the Products section of the Quote.