相关文章推荐
酒量大的板栗  ·  log4j ...·  2 周前    · 
高兴的红酒  ·  C# unsafe code - 简书·  1 年前    · 
逆袭的生菜  ·  mysql sum 重复计算_mysql ...·  1 年前    · 
IHttpUtility Interface
IQuoteItemAttributeValue Interface
IVCResponseItem Interface
Click or drag to resize Click or drag to resize

Scripting Namespace

Classes
Class Description
Public class ByteArrayContent
Wrapper for System.Net.Http.ByteArrayContent.
Public class HttpContent
Wrapper for System.Net.Http.httpContent.
Public class MultipartFormDataContent
Wrapper for System.Net.Http.MultipartFormDataContent.
Public class StreamContent
Wrapper for System.Net.Http.StreamContent.
Public class StreamReader
Wrapper of System.IO.StreamReader for IronPython Scripting with limited set of features
Public class StringContent
Wrapper for System.Net.Http.StringContent.
Interfaces
Interface Description
Public interface Code example IAction
Quote Action
Examples

Execute Reprice action

Python
for action in Quote.Actions:
    if action.Name == "Reprice" and action.IsPrimaryAction:
        Quote.ExecuteAction(action.Id)
        break
Public interface IActionCollection
Quote action collection
Public interface Code example IAdditionalDiscount
Additional discount represent the additional discounts on the quote. User can add/remove/change additional discounts via Scripting.
Examples

Adding new additional discount to quote

Python
ad = Quote.NewAdditionalDiscount();
ad.DiscountPercent = 10;
ad.Description = "New discount added via scripting";
Quote.AddAdditionalDiscount(ad);

Change additional discount

Python
ad = Quote.GetAdditionalDiscount("New discount added via scripting");
ad.DiscountPercent= 5;

Remove additional discount

Python
Quote.RemoveAdditionalDiscount("New discount added via scripting");
Public interface IAdditionalDiscountCollection
Additional discount collection
Public interface IAliases
Alias functions.
Public interface Code example IApiResponse
This is abstract class which represent the response of custom API call. If ApiResponse is not provided within the script the result would be
  • Content type: application/json
  • Body: Ok
See IApiResponseFactory for more details about creating instance of this class.
Examples
Remarks
This code define HTML response after logic in custom API script.
Python
#some custom logic
ApiResponse = ApiResponseFactory.HtmlResponse("some HTML");
Public interface IApiResponseFactory
API Response
Public interface IApproversResponsibility
Approvers Responsibility
Public interface IApproversResponsibilityCollection
Approvers Responsibility Collection
Public interface IAssert
Class containing helper assert methods. Primary usage should be for writing automated tests although it can be used also in production scripts for guard clauses.
Public interface IAssetAttribute
Asset Attribute
Public interface IAssetConfiguration
Asset Configuration
Public interface IAssetContainer
Asset Container
Public interface IAssetContainerRow
Asset Container Row
Public interface IAssetItem
Asset line item
Public interface IAssetMainItem
Asset main item
Public interface IAttachedDocument
Attached document
Public interface IAttachedDocumentCollection
Attached documents collection
Public interface Code example IAuthorizedRestClient
Client for communication with RESTful services using Authorization header built with credentials defined in Credentials Management
Examples

Call current weather data for one location

Call service with providing city name and country/region code. API responds with a list of results that match a searching word.
API call:
http://api.openweathermap.org/data/2.5/weather?q={city name},{country/region code}
Parameters:
q city name and country/region code divided by comma, use ISO 3166 country/region codes
Python
#response is in JSON form of:
#{"main":{"temp":291.05,"pressure":1016,"humidity":88,"temp_min":288.15,"temp_max":296.15},
#"weather":[{"id":701,"main":"Mist","description":"mist","icon":"50n"}],
#"id":5391959,"name":"San Francisco","cod":200,"base":"stations"}
response = RestClient.Get('http://api.openweathermap.org/data/2.5/weather?q=SanFrancisco,usa')
Quote.GetCustomField('City').Content = response.name
Quote.GetCustomField('Weather Today').Content = str(response.weather[0].main)
Quote.GetCustomField('Weather Today Details').Content = str(response.weather[0].description)
Quote.GetCustomField('Weather Temperature MIX').Content = str(response.main.temp_max)
Quote.GetCustomField('Weather Temperature MAX').Content = str(response.main.temp_min)

Submit an HTTPS POST request with basic authentication using credentials defined in Credentials Management and JSON input data to the server

Submits JSON data to be processed to a specified resource and returns JSON response.
Response is deserialized, in order to be used as object in scripting.
Python
#example of url service
url = 'https://testcallidus.com/CallidusPortal/services/some-example-service'
headers = {}
#example of input JSON data
data = '[{"name": "SaaS Net New Revenue", "periodType": "month", "type": "Measurement", "value": { "amount": 100, "unitType": "USD" }}]'
#make HTTPS POST and receive response in form of dynamic entity
response = AuthorizedRestClient.Post('CredentialsFromStore', url, data, headers)
#Populate Quote custom fields
Quote.GetCustomField('Bonus type').Content = response.name
Quote.GetCustomField('Bonus amount').Content = str(response.value.amount)
Quote.GetCustomField('Bonut unit type').Content = response.value.unitType
Public interface IBeforeAddToQuoteEventArguments
Argument provided when 'On AddToQuote' event occurs.
Public interface IBeforeConfigureEventArguments
Argument provided when 'On Configure' event occurs.
Public interface IBeforeProductAddToQuoteEventArgument
Context available for the event raised before product is being added/updated to the quote. Also raised after the item is being reconfigured and before updated back to the quote.
Public interface IBusinessPartner
Business partner interface.
Public interface IBusinessPartnerPermission
Business partner permission.
Public interface IBusinessPartnerRepository
Business partner repository. Used to retrieve data about business partners.
Public interface Code example ICompany
Company information
Examples

Check if user belongs to "SAP" company and notify user using IWorkflowContext within custom action script.

Python
if User.Company.Name == "SAP":
    WorkflowContext.ClientScript = "alert('Welcome to SAP!')";
Public interface Code example IContainer
Container information
Examples

Move container row up

Moving of container row has impact on the total order of container rows, so if row is identified while iterating through container rows
perform moving of row and add break to exit the current iteration. See following code as example.
Python
container = Product.GetContainerByName("Assets")
for row in container.Rows:
    if row['LicenceKey'] == 'Licence 2':
        container.MoveRowUp(row.RowIndex)
        break
Public interface Code example IContainerColumn
Container column information
Public interface IContainerColumnCollection
Container column collection
Public interface IContainerProperty
Container property information
Public interface IContainerPropertyCollection
Container property collection
Public interface IContainerRow
Container row information
Public interface IContainerRowCollection
Container row collection
Public interface ICrmLandingEventArguments
Argument provided when 'On Landing From Crm' event occurs.
Public interface Code example ICustomer
Customer inforamtion
Examples

Check if bill to customer is selected and show alert message using IWorkflowContext within custom action script.

Python
if Quote.BillToCustomer is not None:
WorkflowContext.ClientScript = "alert('" + Quote.BillToCustomer.FirstName + " " + Quote.BillToCustomer.LastName + "')";
Public interface ICustomerHelper
Customer helper interface
Public interface Code example ICustomFieldChangedArgument
Custom field change argument is passed when the custom field change event occurs. This class can be accessed via "arg" variable within the custom field change event handler.
Examples

Using this argument on custom field change script

Python
diff = float(arg.NewValue) - float(arg.OldValue);
Quote.GetCustomField("CustomField1").Content = "You have changed custom field value for " + str(diff) + " points."
Public interface IFederationUtility
Federation helper methods
Public interface IFileHelper
File helper
Public interface IGeneratedDocument
Generated document
Public interface IGeneratedDocumentCollection
Generated documents collection
Public interface IHttpUtility
Provides methods for encoding and decoding URLs when processing Web requests.
Public interface IHttpWebClientProtocol
HttpWebClientProtocol
Public interface IItemAction
Item Action
Public interface IItemActionCollection
Item action collection
Public interface IItemActionId
Public interface IItemCustomField
Item custom field data. Contains additional data related to quote item custom field.
Public interface IItemCustomFieldCollection
Item custom field collection
Public interface IItemInfo
ItemInfo class is used to add additional information to cart item. These additional information can be added via administration.
Public interface IJsonHelper
Represents an object with which we can serialize/deserialize JSON data.
Public interface Code example IKeyAttribute
Key Attributes allow setting up an attribute as search criteria on the user side. This means that the user can search for quotes based on the value of their Key Attributes. User can set input value for Key Attribute via Scripting
Examples

Setting input value without reconfigure for Key Attribute through Scripting

Python
for item in Quote.MainItems:
    if item.GetKeyAttributeByAttributeName("Memory") is not None:
        item.GetKeyAttributeByAttributeName("Memory").SetInputValue("Memory key")

Setting input value with reconfigure for Key Attribute through Scripting

Python
for item in Quote.MainItems:
    if item.GetKeyAttributeByAttributeName("Memory") is not None:
        item.GetKeyAttributeByAttributeName("Memory").SetInputValue("Memory key", True)
    if item.GetKeyAttributeByAttributeName("Processor") is not None:
        item.GetKeyAttributeByAttributeName("Processor").SetInputValue("Processor key", False)

Setting the key attribute value without reconfigure through Scripting

Python
for item in Quote.MainItems:
    if item.GetKeyAttributeByAttributeName("Memory") is not None:
        item.GetKeyAttributeByAttributeName("Memory").SetInputValue("Memory_cpq")

Setting the key attribute value with reconfigure through Scripting

Python
for item in Quote.MainItems:
    if item.GetKeyAttributeByAttributeName("Memory") is not None:
        item.GetKeyAttributeByAttributeName("Memory").SetInputValue("Memory_cpq", True)
    if item.GetKeyAttributeByAttributeName("Processor") is not None:
        item.GetKeyAttributeByAttributeName("Processor").SetInputValue("Processor_cpq", False)
Public interface IKeyAttributeCollection
Key attribute collection
Public interface Code example ILineItem
Line Item
Examples

Getting Key Attribute by attribute system id through Scripting

Python
for mainItem in Quote.MainItems:
    if mainItem.ProductName == "Laptop":
        for lineItem in mainItem.LineItems:
           if lineItem.ProductName == "Laptop bag":
               Quote.GetCustomField("Custom Field 1").Content = lineItem.GetKeyAttribute("laptop_bag_cpq").Label

Getting Key Attribute by attribute name through Scripting

Python
for mainItem in Quote.MainItems:
    if mainItem.ProductName == "Laptop":
        for lineItem in mainItem.LineItems:
           if lineItem.ProductName == "Laptop bag":
               Quote.GetCustomField("Custom Field 2").Content = lineItem.GetKeyAttributeByAttributeName("Laptop Bag").Label

Getting Key Attribute by attribute label through Scripting

Python
for mainItem in Quote.MainItems:
    if mainItem.ProductName == "Laptop":
        for lineItem in mainItem.LineItems:
           if lineItem.ProductName == "Laptop bag":
               Quote.GetCustomField("Custom Field 3").Content = lineItem.GetKeyAttributeByLabel("Laptop Bag").ParsedValue
Python
item = Quote.GetItemByQuoteItem("2.1")
Quote.GetCustomField("Custom Field 4").Content = item.AsLineItem.GetKeyAttributeByLabel("Memory").Label
Public interface ILineItemCollection
Line item collection ILog class write messages to log
Public interface Code example IMainItem
Main item
Examples

Check if copy action is available and execute it

In order to easy get item action id, use item action id constants in following format:
Quote.ItemActionId.CopyItemId, Quote.ItemActionId.EditItemId, Quote.ItemActionId.UpgradeToNewProductVersionItemId etc.
Python
for item in Quote.MainItems:
    if item.PartNumber == "PART-NUMBER-123":
        for action in item.Actions:
            if action.Id == Quote.ItemActionId.CopyItemId:
                item.Copy()

Getting Key Attribute by attribute system id through Scripting

Python
for item in Quote.MainItems:
    if item.GetKeyAttribute("Hard Drive") is not None:
        ka = item.GetKeyAttribute("Hard Drive")
        ka.Label = "Hard Drive"

Getting Key Attribute by attribute name through Scripting

Python
for item in Quote.MainItems:
    if item.GetKeyAttributeByAttributeName("Hard Drive") is not None:
        ka = item.GetKeyAttributeByAttributeName("Hard Drive")
        ka.Label = "Hard Drive"

Getting Key Attribute by attribute label through Scripting

Python
for item in Quote.MainItems:
    if item.GetKeyAttributeByLabel("Hard Drive") is not None:
        ka = item.GetKeyAttributeByLabel("Hard Drive")
        ka.Label = "New label for Hard Drive"
Python
item = Quote.GetItemByQuoteItem("2.1")
Quote.GetCustomField("Custom Field 1").Content = item.AsMainItem.GetKeyAttributeByLabel("Memory").Label

Calculating Rolled Up values of Main Items

Python
miItems = []
for item in Quote.MainItems:
    miItems.append(item)
miItems.reverse()
for mi in miItems:
    mi.RolledUpListPrice = mi.ListPrice
    mi.RolledUpExtendedListPrice = mi.ExtendedListPrice
    mi.RolledUpNetPrice = mi.NetPrice
    mi.RolledUpExtendedAmount = mi.ExtendedAmount
    mi.RolledUpEndCustomerUnitPrice = mi.EndUserNet
    mi.RolledUpEndCustomerExtendedPrice = mi.EndUserExtendedAmount
    mi.RolledUpCost = mi.Cost
    mi.RolledUpExtendedCost = mi.ExtendedCost
    mi.RolledUpDiscountAmount = mi.DiscountAmount
    for li in mi.LineItems:
        if li.IsOptional:
            continue
        mi.RolledUpListPrice += li.ListPrice
        mi.RolledUpExtendedListPrice += li.ExtendedListPrice
        mi.RolledUpNetPrice += li.NetPrice
        mi.RolledUpExtendedAmount += li.ExtendedAmount
        mi.RolledUpEndCustomerUnitPrice += li.EndUserNet
        mi.RolledUpEndCustomerExtendedPrice += li.EndUserExtendedAmount
        mi.RolledUpCost += li.Cost
        mi.RolledUpExtendedCost += li.ExtendedCost
        mi.RolledUpDiscountAmount += li.DiscountAmount

Inline edit of existing configurable item on the quote

Configuration of quote main item can be updated automatically through scripting without leaving currently opened quote (for example, by clicking custom quote action with following script example).
All quote calculations will be executed in the same way as item is manually updated from the configurator.
Important note - rules will not be triggered when attribute values are modified through scripting.
To enforce standard CPQ rules' execution, add Product.ApplyRules() before doing update of configuration.
Python
for mainItem in Quote.MainItems:
    if mainItem.ProductName == 'Maintenance':
        mainItem.Edit()
        Product.Attributes.GetByName('Maintenance duration').SelectValue('5-YEARS')
        Product.Attributes.GetByName('Contract Type').AssignValue('Updated contract')
        if Product.Attributes.GetByName('1 Year Support').SelectedValue is not None:
            Product.Attributes.GetByName('1 Year Support').SelectedValue.IsSelected = False
        Product.UpdateQuote()
        break
Public interface IMainItemCollection
Main item collection
Public interface IMarket
Market
Public interface Code example ImutualTLSRestClient
Client for communication with RESTful services using client certificates
Examples

Call current weather data for one location

Call service with providing city name and country/region code. API responds with a list of results that match a searching word.
API call:
http://api.openweathermap.org/data/2.5/weather?q={city name},{country/region code}
Parameters:
q city name and country/region code divided by comma, use ISO 3166 country/region codes
Python
#response is in JSON form of:
#{"main":{"temp":291.05,"pressure":1016,"humidity":88,"temp_min":288.15,"temp_max":296.15},
#"weather":[{"id":701,"main":"Mist","description":"mist","icon":"50n"}],
#"id":5391959,"name":"San Francisco","cod":200,"base":"stations"}
response = mTLSRestClient.Get('ApiCertificate', 'http://api.openweathermap.org/data/2.5/weather?q=SanFrancisco,usa')
Quote.GetCustomField('City').Content = response.name
Quote.GetCustomField('Weather Today').Content = str(response.weather[0].main)
Quote.GetCustomField('Weather Today Details').Content = str(response.weather[0].description)
Quote.GetCustomField('Weather Temperature MIX').Content = str(response.main.temp_max)
Quote.GetCustomField('Weather Temperature MAX').Content = str(response.main.temp_min)

Submit an HTTPS POST request with client certificate authentication and JSON input data to the server

Submits JSON data to be processed to a specified resource and returns JSON response.
Response is deserialized, in order to be used as object in scripting.
Python
#example of url service
url = 'https://testcallidus.com/CallidusPortal/services/some-example-service'
headers = { }
#example of input JSON data
data = '[{"name": "SaaS Net New Revenue", "periodType": "month", "type": "Measurement", "value": { "amount": 100, "unitType": "USD" }}]'
#make HTTPS POST and receive response in form of dynamic entity
response = RestClient.Post('AuthorizationCertificate' ,url, data, headers)
#Populate Quote custom fields
Quote.GetCustomField('Bonus type').Content = response.name
Quote.GetCustomField('Bonus amount').Content = str(response.value.amount)
Quote.GetCustomField('Bonut unit type').Content = response.value.unitType
Public interface IPartnerFunction
Partner function interface.
Public interface IPartnerFunctionRepository
Partner function repository. Used to retrieve data about partner functions.
Public interface IPartnerFunctionTranslation
Partner function translation interface.
Public interface IPostedFile
Posted File information
Public interface IProduct
Product information
Public interface IProductAddEditArgument
Product added/updated argument is passed when the product added/updated to the quote event occurs.
Public interface IProductAttribute
Product attribute information
Public interface IProductAttributeCollection
Product attribute collection
Public interface IProductAttributeValue
Product attribute value information
Public interface IProductAttributeValueCollection
Product attribute value collection
Public interface IProductBeforeAddToQuoteEventArgument
Before product Add to quote argument is passed before 'Product is added to the quote' event occurs.
Public interface IProductErrorMessages
Product error messages. Messages are shown in the responder part of the configurator as errors.
Public interface Code example IProductHelper
Helper class which allow us to globally manipulate the products.
Examples

Check if product is simple by product's system id

Python
if ProductHelper.IsSimpleProduct("Laptop_Computer_cpq"):
    Quote.GetCustomField("SimpleProducts").Content = "Laptop is simple product"
else:
    Quote.GetCustomField("SimpleProducts").Content = "Laptop is configurable product"

Inline adding new product with configuration to the quote

Product with configuration can be configured and added automatically through scripting without leaving currently opened quote (for example, by clicking custom quote action with following script example)
or can be inlined configured and added from other product's configurator through script attached on some product event
(When product rule execution ends, When product configuration is completed, Before Add to quote, When product is added to quote etc.).
All quote calculations will be executed in the same way as item is manually added from the configurator.
Important note - rules will not be triggered when attribute values are modified through scripting.
To enforce standard CPQ rules' execution, add Product.ApplyRules() before doing update of configuration.
Python
inlineProduct = ProductHelper.CreateProduct('Maintenance_cpq')
inlineProduct.Attributes.GetByName('1 Year Support').SelectValue('1')
inlineProduct.Attributes.GetByName('Maintenance duration').SelectValue('1-YEAR')
inlineProduct.Attributes.GetByName('Contract Type').AssignValue('New contract signed')
inlineProduct.AddToQuote()
Public interface IProductInfo
Provides information about a product exposed on 'On Configure' event.
Public interface IProductMessages
Product configuration template messages. Messages are shown in the responder part of the configurator.
Public interface IProductTab
Product Tab information
Public interface Code example IProductTabChangedArgument
Product tab change argument is passed when the product tab change event occurs. This class can be accessed via "arg" variable within the product tab change event script.
Examples

Using this argument on product tab change script

Python
if arg.NameOfCurrentTab == 'Second tab':
    Product.Attributes.GetByName("Message").AssignValue("You have changed tab from " + arg.NameOfPreviousTab + " to " + arg.NameOfCurrentTab);
Public interface IProductTabCollection
Product tab collection
Public interface IProductType
Product Type information
Public interface Code example IProductTypeItem
Represent product type quote item
Examples

Setting product type's discount amount according to subtotal for currently selected market

Python
for productTypeItem in Quote.ProductTypes:
    if productTypeItem.SubtotalInMarket > 1500:
        productTypeItem.DiscountAmount = 250
    else:
        productTypeItem.DiscountAmount = 50
Public interface IProductTypeItemCollection
Product type item collection
Public interface IProductValidationMessage
Product Validation Message
Public interface IProductValidationMessageCollection
Product validation message collection
Public interface Code example IQuote
Quote
Examples

Execute quote action

In order to easy get quote action id, use action id constants in following format:
Quote.QuoteActionId.ViewQuoteId, Quote.QuoteActionId.DeleteQuoteId, Quote.QuoteActionId.ArchiveQuoteId, Quote.QuoteActionId.CopyQuoteId, Quote.QuoteActionId.QuoteWonId etc.
Python
Quote.ExecuteAction(Quote.QuoteActionId.PlaceOrderId)

Adding new additional discount to quote

See IAdditionalDiscount how to set additional discount in the quote

Attaching the specified Opportunity to quote

Python
Copy
Quote.AttachToQuote("0063000000aiy99AAA")

Changing Quote Status to specified Quote Status

Python
Quote.ChangeQuoteStatus("Waiting for Approval")

Determining whether quote contails any Product with specified system id(s)

Python
if Quote.ContainsAnyProduct("SMB_Desktop_computer_cpq", "Laptop_IBM_cpq"):
Quote.CustomFields.DisallowValues("Custom Field Name 1", "Custom Field Value 1", "Custom Field Value 2")

Determining whether quote contains any Product with specified product name(s)

Python
if Quote.ContainsAnyProductByName("SMB Desktop", "Laptop IBM"):
Quote.CustomFields.Allow("Hard Drive", "Memory")

Determining whether quote contains any Product with specified part number(s)

Python
if Quote.ContainsAnyProductByPartNumber("SMB 12345", "IBM 12345")
Quote.CustomFields.Allow("Hard Drive", "Memory")

Determining whether quote contains any item with specified Product Type system id(s)

Python
if Quote.ContainsAnyProductType("Hardware_cpq", "Software_cpq")
Quote.GetCustomField("Info").Content = "Quote is containing hardware and software products"

Determining whether quote contains any item with specified Product Type name(s)

Python
if Quote.ContainsAnyProductTypeByNames("Hardware", "Software")
Quote.GetCustomField("Info").Content = "Quote is containing hardware and software products"

Getting Additional Discount from quote

See IAdditionalDiscount how to get additional discount in the quote

Getting Custom Field by strong name

See IQuoteCustomField how to get custom field by strong name

Getting Quote Item by quote item

Python
if Quote.GetItemByQuoteItem(1) is not None:
Quote.GetCustomField("Custom Field 1").Content = Quote.GetItemByQuoteItem(1).AsMainItem.RolledUpExtendedAmount
Python
if Quote.GetItemByQuoteItem("1.1") is not None:
Quote.GetCustomField("Custom Field 2").Content = Quote.GetItemByQuoteItem("1.1").AsMainItem.RolledUpDiscountAmount

Getting Quote Item by unique identifier

Python
if Quote.GetItemByUniqueIdentifier("293f526d-37ad-4c7b-af66-182a7d3f3f0d") is not None:
Quote.GetCustomField("Custom Field 3").Content = Quote.GetItemByUniqueIdentifier("293f526d-37ad-4c7b-af66-182a7d3f3f0d").AsMainItem.ShippingCostInMarket

Getting Items by Product Type system id

Python
quoteItems = Quote.GetItemsByProductTypeSystemId("Hardware_cpq")
for item in quoteItems:
totalHardwarePrice = totalHardwarePrice + item.ListPriceInMarket

Getting latest generated Document File

Python
fileName = Quote.GetLatestGeneratedDocumentFileName()

Getting latest generated Document File in bytes

Python
fileInBytes = Quote.GetLatestGeneratedDocumentInBytes()

Getting generated document list

Python
docList = Quote.GetGeneratedDocumentList()

Getting generated document list by template name

Python
docList = Quote.GetGeneratedDocumentList("templateName")

Getting attached document list

Python
Copy
docList = Quote.GetAttachedDocumentList()

Getting attached document by document id

Python
doc = Quote.GetAttachedDocument(100)

Getting Product Type Item by specified product type system id

Python
if Quote.GetProducType("Software_cpq") is not None:
Quote.GetCustomField("Custom Field 1").Content = Quote.GetProducType("Software_cpq").ProductTypeNameTranslated

Getting Product Type Item by specified product type name

Python
if Quote.GetProductTypeByName("Software") is not None:
Quote.GetCustomField("Custom Field 1").Content = Quote.GetProductTypeByName("Software").ProductTypeNameTranslated

Creating new additional discount

See IAdditionalDiscount how to create additional discount in the quote

Removing additional discount

See IAdditionalDiscount how to remove additional discount from the quote

Create new revision for the quote and set it active

See IQuoteInfo how to create new active revision.

Showing custom messages

Python
Quote.Messages.Add("message")
Public interface IQuoteActionId
Public interface Code example IQuoteCustomField
Quote Custom Field
Examples

Setting content of Custom Field

Python
Quote.GetCustomField("Custom Field 1").Content = "new content"

Getting content of Custom Field

Python
if Quote.GetCustomField("Custom Field 1") is not None:
    cf = Quote.GetCustomField("Custom Field 1").Content

Setting visibility of Custom Field

Python
Quote.GetCustomField("Custom Field 2").Visible = False

Setting label of Custom Field.
Label will be dynamically named by a line item which is simple attribute from the configuration in the quote.

Python
if Quote.GetItemByQuoteItem(1) is not None:
    Quote.GetCustomField("Custom Field 3").Label = Quote.GetItemByQuoteItem(3).AsLineItem.AttributeName
Public interface Code example IQuoteCustomFieldAttributeValue
Quote Custom Field Attribute Value
Examples

Disallow Custom Field attribute value

Python
customField = Quote.GetCustomField("CD or DVD drive")
for value in customField.AttributeValues:
    if value.DisplayValue == "Combo DVD/CD-R 12/52/16/52":
        value.Allowed = False

Set Custom Field attribute value code as Custom Field content

Python
customField = Quote.GetCustomField("CD or DVD drive")
for value in customField.AttributeValues:
    if value.DisplayValue == "Combo DVD/CD-R 12/52/16/52":
        Quote.GetCustomField("Custom Field 1").Content = value.ValueCode
Public interface IQuoteCustomFieldAttributeValueCollection
Quote custom field attribute value collection
Public interface Code example IQuoteCustomFieldCollection
Quote custom field collection
Remarks
The IQuoteCustomFieldCollection class wrap the list of IQuoteCustomField and expose the methods for quote custom fields manipulations.
Examples

Allowing Custom Field(s) by strong name(s)

Python
Copy
Quote.CustomFields.Allow("Custom Field Name 1")
Python
Quote.CustomFields.Allow("Custom Field Name 1", "Custom Field Name 2", "Custom Field Name 3")

Disallowing Custom Field(s) by strong name(s)

Python
Quote.CustomFields.Disallow("Custom Field Name 1")
Python
Quote.CustomFields.Disallow("Custom Field Name 1", "Custom Field Name 2", "Custom Field Name 3")

Allowing value of Custom Field by custom field's strong name and attribute value system id

Python
Quote.CustomFields.AllowValue("Custom Field Name 1", "Custom_Field_1_Value_1_cpq")

Allowing values of Custom Field by custom field's strong name and attribute value system ids

Python
Quote.CustomFields.AllowValues("Custom Field Name 1", "Custom_Field_1_Value_1_cpq", "Custom_Field_1_Value_2_cpq")

Allowing value of Custom Field by custom field's strong name and attribute value code

Python
Quote.CustomFields.AllowValueByValueCode("Custom Field Name 1", "Value 1")

Allowing values of Custom Field by custom field's strong name and attribute value codes

Python
Quote.CustomFields.AllowValuesByValueCodes("Custom Field Name 1", "Value 1", "Value 2", "Value 3")

Disallowing value of Custom Field by custom field's strong name and attribute value system id

Python
Quote.CustomFields.DisallowValue("Custom Field Name 1", "Custom_Field_1_Value_1_cpq")

Disallowing values of Custom Field by custom field's strong name and attribute value system ids

Python
Quote.CustomFields.DisallowValues("Custom Field Name 1", "Custom_Field_1_Value_1_cpq", "Custom_Field_1_Value_2_cpq")

Disallowing value of Custom Field by custom field's strong name and attribute value code

Python
Quote.CustomFields.DisallowValueByValueCode("Custom Field Name 1", "Value 1")

Disallowing values of Custom Field by custom field's strong name and attribute value codes

Python
Quote.CustomFields.DisallowValuesByValueCodes("Custom Field Name 1", "Value 1", "Value 2", "Value 3")

Assigning the specified text to Custom Field.

Python
Quote.CustomFields.AssignValue("Custom Field Name 1", "New text value")

Disallowing all Custom Field Values except values with specified attribute value system id(s)

Python
Quote.CustomFields.DisallowAllValuesExcept("Custom Field Name 1", "Custom_Field_1_Value_1_cpq")
Python
Quote.CustomFields.DisallowAllValuesExcept("Custom Field Name 1", "Custom_Field_1_Value_1_cpq", "Custom_Field_1_Value_2_cpq")

Disallowing all Custom Field Values except values with specified attribute value code(s)

Python
Quote.CustomFields.DisallowAllValuesExceptByValueCodes("Custom Field Name 1", "Value 1")
Python
Copy
Quote.CustomFields.DisallowAllValuesExceptByValueCodes("Custom Field Name 1", "Value 1", "Value 2", "Value 3")

Selecting Custom Field Value by attribute value system id.

Python
Quote.CustomFields.SelectValue("Custom Field Name 1", "Custom_Field_1_Value_1_cpq")

Selecting Custom Field Value by attribute value code.

Python
Quote.CustomFields.SelectValueByValueCode("Custom Field Name 1", "Value 1")

Reseting the custom field(s)

Python
Quote.CustomFields.Reset("Custom Field Name 1")
Python
Quote.CustomFields.Reset("Custom Field Name 1", "Custom Field Name 2", "Custom Field Name 3")

Setting the specifed Custom Field(s) optional

Python
Quote.CustomFields.SetOptional("Custom Field Name 1")
Python
Quote.CustomFields.SetOptional("Custom Field Name 1", "Custom Field Name 2", "Custom Field Name 3")

Setting the specifed Custom Field(s) required

Python
Quote.CustomFields.SetRequired("Custom Field Name 1")
Python
Quote.CustomFields.SetRequired("Custom Field Name 1", "Custom Field Name 2", "Custom Field Name 3")
Public interface Code example IQuoteHelper
Helper class which allow us to globally manipulate the quotes.
Examples

Reassign quote to specified user

Return parameter is of type IQuoteInfo ,
containing new quote id, new user id, new composite quote number and new composite quote number crypted.
Python
quoteInfo = QuoteHelper.Reassign("00021520", "jsmith", True)

Dispose currently loaded quote environment in order to delete quote

Executing delete on currently loaded quote will cause break.
In order to delete loaded quote, it should be first disposed by using Quote.Dispose() - IQuote .
Python
quoteCompositeNumber = Quote.CompositeNumber
Quote.Dispose()
QuoteHelper.Delete(quoteCompositeNumber)
Public interface Code example IQuoteInfo
Quote Info helper
Examples

Create new active revision and get data for new revision

Python
revisionInfo = Quote.CreateNewRevision(True)
Public interface Code example IQuoteItem
Represent abstract class which expose common interface for main and line items
Examples

Getting Quote Item as main item and setting it's mrc rolled up extended cost for currently selected market as custom field content

Python
item = Quote.GetItemByUniqueIdentifier("293f526d-37ad-4c7b-af66-182a7d3f3f0d")
Quote.GetCustomField("Custom Field 1").Content = item.AsMainItem.MrcRolledUpExtendedCostInMarket

Getting Quote Item as line item and setting it's translated attribute name as custom field content

Python
item = Quote.GetItemByUniqueIdentifier("293f526d-37ad-4c7b-af66-182a7d3f3f0d")
Quote.GetCustomField("Custom Field 2").Content = item.AsLineItem.AttributeNameTranslated

Getting Key Attribute by attribute system id through Scripting

See IMainItem and ILineItem how to get key attribute by attribute system id through Scripting

Getting Key Attribute by attribute name through Scripting

See IMainItem and ILineItem how to get key attribute by attribute name through Scripting

Getting Key Attribute by attribute label through Scripting

See IMainItem and ILineItem how to get key attribute by attribute label through Scripting
Public interface IQuoteItemAttribute
Represents attribute of the product referenced in Quote Item
Public interface IQuoteItemAttributeCollection
Collection of all attributes selected in product referenced in Quote Item
Public interface IQuoteItemAttributeValue
Represents selected value of the attribute of referenced product in Quote Item
Public interface IQuoteItemCollection
Quote item collection
Public interface IQuoteItemContainer
Represents container attribute of quote item
Public interface IQuoteItemContainerColumn
Represents column of container attribute referenced in quote item's product
Public interface IQuoteItemContainerColumnCollection
Collection of container columns
Public interface IQuoteItemContainerProperty
Represent property of quote item's container attribute
Public interface IQuoteItemContainerPropertyCollection
Represents collection of container properties of quote item's container attribute
Public interface IQuoteItemContainerRow
Represent row of quote item's container attribute
Public interface IQuoteItemContainerRowCollection
Represents collection of rows of quote item's container attribute
Public interface Code example IQuoteItemCustomField
Quote item custom fields are basically additional quote columns that can store values of different types (number, currency, date or text).
Examples

Setting value for specified quote item

Python
Quote.GetItemByUniqueIdentifier("4dbc4075-67a3-43ab-b121-9792f0abc18b")["textfield"].Value = "some text"
Quote.GetItemByUniqueIdentifier("4dbc4075-67a3-43ab-b121-9792f0abc18b")["numberfield"].Value = 123
Public interface Code example IQuoteOrderStatus
Quote Order Status
Examples

Getting Quote Order Status translated name in currently selected language

Python
if Quote.OrderStatus is not None:
    if Quote.OrderStatus.NameTranslated == "Waiting for Approval":
        Quote.ChangeQuoteStatus("Approved")
Public interface Code example IQuoteTotal
Quote Total
Examples

Setting Total Shipping Cost according to Total List Price in currently selected market

Python
if Quote.Total.TotalListPriceInMarket > 15000:
    Quote.Total.ShippingCost = Quote.Total.TotalListPrice - Quote.Total.Cost

Setting Quote Total Tax Percent

If Quote Total column is not editable on the quote, set Quote Total Tax Percent as State tax percent
Python
if ((Quote.Total.IsFieldEditable("TaxPercent") is False) and (Quote.Total.IsFieldEditable("TaxAmount") is False)):
    taxPercent = 0.0
    if Quote.ShipToCustomer is not None and len(Quote.ShipToCustomer.StateAbbreviation) > 0:
        taxPercent = SqlHelper.GetFirst("select SALES_TAX_RATE from STATE_TAX where STATE_SHORT_NAME='" + \
        Quote.ShipToCustomer.StateAbbreviation + "'")
    Quote.Total.TaxPercent = taxPercent

Setting Quote Total Amount

If Tax should be included in Total Price, set Quote Total Amount as sum of Total Shipping Cost, Total Tax Amount and Total Vat Amount
Python
result += Quote.Total.ShippingCost
if Quote.IncludeTaxInTotalPrice:
    result += Quote.Total.TaxAmount
    result += Quote.Total.VatAmount
Quote.Total.TotalAmount = result

Setting Monthly Recurring (MRC) Total Amount

Setting Monthly Recurring Amount as sum of MRC Subototal Amount, MRC Vat Amount and MRC Tax Amount
Python
Quote.Total.MrcTotalAmount = Quote.Total.MrcSubtotalAmount + Quote.Total.MrcVatAmount + Quote.Total.MrcTaxAmount
Public interface Code example IQuoteTotalCustomField
Total on quote or product type level for quote item custom field.
Examples

Setting value for specified quote item

Python
Quote.GetCustomField("Test").Content = str(Quote.Total["mycustomfield"].MaximumCV)
for productTypeItem in Quote.ProductTypes:
    if productTypeItem.ProductTypeName == "Hardware":
        Quote.GetCustomField("Test").Content = str(productTypeItem["mycustomfield"].MaximumCV + 3)
Public interface IReadOnlyProductMessages
Product configuration template messages. Messages are shown in the responder part of the configurator.
Public interface Code example IRequest
Represent class for manipulation with user request.
Public interface IRequestContext
RequestContext represents a CPQ helper class that can be used to store additional information and entities that would be shared across one HTTP request Items set in one script have the validity equal to one HTTP request
Public interface IRequestItems
Represents the key value collection that has a life cycle of one HTTP request
Public interface Code example IRestClient
Client for communication with RESTful services
Examples

Call current weather data for one location

Call service with providing city name and country/region code. API responds with a list of results that match a searching word.
API call:
http://api.openweathermap.org/data/2.5/weather?q={city name},{country/region code}
Parameters:
q city name and country/region code divided by comma, use ISO 3166 country/region codes
Python
#response is in JSON form of:
#{"main":{"temp":291.05,"pressure":1016,"humidity":88,"temp_min":288.15,"temp_max":296.15},
#"weather":[{"id":701,"main":"Mist","description":"mist","icon":"50n"}],
#"id":5391959,"name":"San Francisco","cod":200,"base":"stations"}
response = RestClient.Get('http://api.openweathermap.org/data/2.5/weather?q=SanFrancisco,usa')
Quote.GetCustomField('City').Content = response.name
Quote.GetCustomField('Weather Today').Content = str(response.weather[0].main)
Quote.GetCustomField('Weather Today Details').Content = str(response.weather[0].description)
Quote.GetCustomField('Weather Temperature MIX').Content = str(response.main.temp_max)
Quote.GetCustomField('Weather Temperature MAX').Content = str(response.main.temp_min)

Submit an HTTPS POST request with autorization and JSON input data to the server

Submits JSON data to be processed to a specified resource and returns JSON response.
Response is deserialized, in order to be used as object in scripting.
Python
#example of url service
url = 'https://testcallidus.com/CallidusPortal/services/some-example-service'
#example of user autorization header
headers = { 'authorization': RestClient.GetBasicAuthenticationHeader('SAPUsername', 'SAPPassword') }
#example of input JSON data
data = '[{"name": "SaaS Net New Revenue", "periodType": "month", "type": "Measurement", "value": { "amount": 100, "unitType": "USD" }}]'
#make HTTPS POST and receive response in form of dynamic entity
response = RestClient.Post(url, data, headers)
#Populate Quote custom fields
Quote.GetCustomField('Bonus type').Content = response.name
Quote.GetCustomField('Bonus amount').Content = str(response.value.amount)
Quote.GetCustomField('Bonut unit type').Content = response.value.unitType
Public interface IRestServiceHelper
Represent abstract class which expose common interface for supporting Litmos integration with CPQ. See 'How To Integrate With Litmos' for details of how to support integration.
Public interface Code example ISalesArea
Class which allow us to fetch sales area data. Class represents the combination of Sales Organization, Distribution Channel and Division
Examples

Get the distribution channel

Return parameter is of type String ,
Python
distributionChannel = SalesArea.DistributionChannel

Get the sales area division

Return parameter is of type String ,
Python
division = SalesArea.Division

Get the sales organization

Return parameter is of type String ,
Python
salesOrganization = SalesArea.SalesOrganization
Public interface ISapPassport
Represent interface for creating SAP Passport headers. Visit following link for more information: https://help.sap.com/doc/f53c64b93e5140918d676b927a3cd65b/Cloud/en-US/docs-en/guides/features/tracing/android/passport.html
Public interface Code example IScriptExecutor
API that gives you ability to run script from another script. Script that's executed needs to be active.
Examples

To execute script from the current code, use the following call:

Python
ScriptExecutor.Execute("My_Script")

If the script you're executing returns a value, use the following code:

Python
result = ScriptExecutor.Execute("My_Script")
# **** SCRIPT WHICH RETURNS SOME VALUE MUST SET THAT VALUE TO VARIABLE NAMED 'Result' ****
# example: My_Script
# .... logic here...
x = "some return value..."
Result = x

In case the script name is not valid or script is not active, Execute() method will return 'None' value.

You can also provide input parameters that are required in called script. All input parameters should be put in dictionary:

Python
result = ScriptExecutor.Execute("My_Script", {'ID':5, 'Name': 'John', 'Company': 'ABC Inc'})
# In script "My_Script", you can use these input parameters by consuming variable 'Param' like follows:
#...logic here...
name = Param.Name
id = Param.ID
company = Param.Company
# note that Param properties must be named exactly the same as input parameters in Execute() method 
Product.Attributes.GetByName("Name").AssignValue(name)
Product.Attributes.GetByName("Id").AssignValue(id)
Product.Attributes.GetByName("Company").SelectValue(company)
#......
Examples

To execute global script from the current code, use the following call:

Python
ScriptExecutor.ExecuteGlobal("My_Global_Script")

If the global script you're executing returns a value, use the following code:

Python
result = ScriptExecutor.ExecuteGlobal("My_Global_Script")
# **** GLOBAL SCRIPT WHICH RETURNS SOME VALUE MUST SET THAT VALUE TO VARIABLE NAMED 'Result' ****
# example: My_Global_Script
# .... logic here...
x = "some return value..."
Result = x

In case the global script name is not valid or global script is not active, ExecuteGlobal() method will return 'None' value.

You can also provide input parameters that are required in called global script. All input parameters should be put in dictionary:

Python
result = ScriptExecutor.ExecuteGlobal("My_Global_Script", {'ID':6, 'Name': 'Jack', 'Company': 'DEF Inc'})
# In script "My_Global_Script", you can use these input parameters by consuming variable 'Param' like follows:
#...logic here...
name = Param.Name
id = Param.ID
company = Param.Company
# note that Param properties must be named exactly the same as input parameters in ExecuteGlobal() method 
Product.Attributes.GetByName("Name").AssignValue(name)
Product.Attributes.GetByName("Id").AssignValue(id)
Product.Attributes.GetByName("Company").SelectValue(company)
#......
Public interface IScriptingMarket
Market
Public interface IScriptingMarketCollection
Public interface ISelectedDictionary
Represents the selected dictionary.
Public interface Code example ISession
Represents class for keeping an object within the session.
These objects can be shared among scripts.
Lifetime of these objects ends when the user signs out.
Public interface Code example IShipping
Shipping
Examples

Assign selected Shipping Name to custom field

Python
if Quote.SelectedShipping is not None:
    Quote.GetCustomField("Custom Field 1").Content = Quote.SelectedShipping.ShippingName

Set Total Shipping Cost

If Shipping is loaded for all items and Shipping column is not editable, set Total Shipping Cost
Python
if Quote.IsShippingLoadedForAllItems and item.IsMainItem and (Quote.SelectedShipping is not None) and \
(Quote.SelectedShipping.Editable is False):
    Quote.Total.ShippingCost += item.AsMainItem.ShippingCost * item.AsMainItem.Quantity
Public interface ISoapHttpClientProtocol
SoapHttpClientProtocol
Public interface Code example ISqlHelper
Helper class which allows us to pull data from database using SQL select statements.
Examples

Insert/Update example

Python
#insert
tableInfo = SqlHelper.GetTable("ITEMMASTERFROMNS")
tablerow = { "item_internal_id" : itemInternalId, "item_sku" : sku }
tableInfo.AddRow(tablerow)
upsertResult = SqlHelper.Upsert(tableInfo)
#update
tablerow = { "CpqTableEntryId" : currentQuoteCpqTableEntryId, "OpportunityId" : oppId, "QuoteNumber" : Quote.CompositeNumber, "IsPrimary" : 1 }
tableInfo.AddRow(tablerow)
SqlHelper.Upsert(tableInfo)

Delete example

Python
Copy
primaryQueryItems = SqlHelper.GetList("select CpqTableEntryId, OpportunityId, QuoteNumber, ItemGuid, OpportunityProductID from OpportunityQuoteItems where OpportunityId = '{0}' and QuoteNumber={1}".format(oppId, primaryQuoteNumber))
tableInfo = SqlHelper.GetTable("OpportunityQuoteItems")
for primaryItem in primaryQueryItems:
    tableInfo.AddRow(primaryItem)
SqlHelper.Delete(tableInfo)
Public interface Code example ISqlHelperInfo
Sql Helper Info
Examples

Provide result info for SqlHelper methods

Python
sqlInfo = SqlHelper.Upsert(tableInfoData, tableName)
Public interface ISqlParameter
Represents a parameter of a SQL statement, which is used for creation of parameterized SQL queries.
Public interface IStreamReader
Wrapper of System.IO.StreamReader for IronPython Scripting with limited set of features
Public interface Code example ITableColumnInfo
TableColumnInfo
Examples

Provide description of a table column including name, type, size and if it can be null

Python
Public interface Code example ITableDataRow
TableDataRow
Examples

Data in a row that will be used to insert, update or delete a row in custom table.

Python
Public interface Code example ITableInfo
Table Info
Examples

Table definition including name, list of columns, data rows that will be used for upsert or delete and IsNew flag to indicate if table doesn't exist and new table will be created

Python
Public interface Code example ITagParserProduct
Tag parser product
Examples

Parsing product tab expression

Python
if float(TagParserProduct.ParseString("<* TotalPrice *>")) > 3000:
    Quote.Total.Cost = 300
Public interface Code example ITagParserQuote
Tag parser quote
Examples

Parsing quote tab expression

Python
if TagParserQuote.ParseString("<* CustomerCompany *>") == "SAP":
    Quote.GetCustomField("Customer company") = "SAP company"
Public interface ITechnicalDocumentation
Technical Documentation Helper
Public interface Code example ITerritory
Territory
Examples

Getting Territory name as Custom Field value through Scripting

Python
if User.Territory is not None:
    Quote.GetCustomField("Territory").Content = User.Territory.Name
Public interface ITrace
ITrace write messages to trace.
Use this class for debugging scripts.
Public interface Code example ITranslation
Dictionary key/value translation
Examples

Set translated value from the specified dictionary to Free Form attribute

In this example it is assumed that dictionary id for German dictionary is 2. Dictionary key is - CustomDictionary.CurrentlyLoggedUser.
Python
Product.Attributes.GetByName('Translation attribute').AssignValue(Translation.Get(2, 'CustomDictionary.CurrentlyLoggedUser'))

Set formatted translated value from currently set dictionary to Free Form attribute

Dictionary key is - CustomDictionary.CurrentlyLoggedUser.
Value for dictionary key is - Currently logged user: {{user}}.
Python
Product.Attributes.GetByName('Translation attribute').AssignValue(Translation.GetFormatted('CustomDictionary.CurrentlyLoggedUser', 'user', User.Name))

Set multiple values' formatted translated value from currently set dictionary to Free Form attribute

Dictionary key is - CustomDictionary.CurrentlyLoggedUser.
Value for dictionary key is - Currently logged user: {{user}}, username {{userName}}.
Data for currently logged user (user's name and username) will be retrieved based on User.Name and User.UserName.
Python
Product.Attributes.GetByName('Translation attribute').AssignValue(Translation.GetFormatted('CustomDictionary.CurrentlyLoggedUser', 'user', User.Name, 'userName', User.UserName))
Public interface Code example IUser
Examples

Setting user's custom field content if user is Flo admin

Python
if User.IsFloAdmin:
    User.GetUserCustomFieldByName("FloAdmin").Content = "User is Flo admin"
Public interface Code example IUserCustomField
User custom field
Examples

Setting the content of User Custom Field

Python
if User.GetUserCustomFieldByName("User Company Name") is not None:
    User.GetUserCustomFieldByName("User Company Name").Content = "SAP company"
Public interface IUserCustomFieldAttributeValue
User custom field attribute value
Public interface IUserCustomFieldAttributeValueCollection
User custom field attribute values
Public interface IUserCustomFieldCollection
User custom field collection
Public interface IUserPersonalizationHelper
Some IronPython built-in functions used in scripts return values in a format that's different from user's selected format (for example, the function str() returns a string in the format 1234.56 which may cause issues if the user format is 1.234,56). To avoid any issues, instead of Iron Python built-in functions, use the IUserPersonalizationHelper methods which will always return values in the user's format.
Public interface Code example IUserType
User type
Examples

Setting user's custom field according to user type

Python
if User.UserType is not None and User.UserType.Name == "Sales Manager":
    User.GetUserCustomFieldByName("User Type").Content = "Sales Manager at SAP"
Public interface IVCCondition
Pricing Condition result
Public interface IVCConditionsWithPurpose
Conditions with purpose
Public interface IVCPricingResponse
VC pricing response
Public interface IVCResponseItem
Pricing item result
Public interface IVCSubtotal
Subtotal
Public interface IWebServiceHelper
Web service helper class
Public interface Code example IWorkbook
Excel workbook of the file loaded in the product configurator.
Public interface IWorkbookCells
Cells object of current excel worksheet.
Public interface IWorkbookSheet
Excel worksheet.
Public interface IWorkflowContext
This class is shared within pre and post actions.
Public interface IXmlHelper
Xml helper
Enumerations
Enumeration Description
Public enumeration AssetStatus
Asset Statuses
Public enumeration AttributeAccess
Product attribute access restriction enum
Public enumeration Encodings
Represents mostly used Encoding types for creating StringContent.
Public enumeration GenDocFormat