Click or drag to resize

Scripting.Quote Namespace

This section explains Quote 2.0 interfaces.
Interfaces
 InterfaceDescription
Public interfaceIAfterQuoteTableExcelUploadedFor Quote 2.0 only.
When Excel is uploaded into a Quote Table - Represents on quote table excel uploaded event
Public interfaceIAsset Represent a Asset
Public interfaceIAssetCollection 
Public interfaceIAssetHistoryItem Represent a Asset item
Public interfaceIAssetHistoryItemCollection Asset item collection
Public interfaceCode exampleIMarketBaseFor Quote 2.0 only.
Represents Quote market
Example

Getting value of Selected Market Name. All the properties are read-only.

Python
selectedMarket = context.Quote.SelectedMarket
Trace.Write(selectedMarket.Name)
Public interfaceCode exampleIQuoteFor Quote 2.0 only.
Represents a quote
Example

Different ways to get Quote Custom fields

Python
customField1 = context.Quote.GetCustomField("Custom Field 1 name")

If you want to get only the Value, you can access it via indexer

Python
customFieldValue = context.Quote["Custom Field 1 name"]

Change Status of the Quote

Python
context.Quote.ChangeStatus("Preparing")

Different ways add items to the Quote

Python
quote = context.Quote
productId = 2
quantity = 5
systemId = 123
quote.AddItem(productId)
quote.AddItem(productId, quantity)
quote.AddItem(systemId)
quote.AddItem(systemId, quantity)
If enabled, multiple items can be added to a quote in bulk using the following code:
Python
from Scripting import AddItemArgument
quote = context.Quote
firstProductId = 2
secondProductId = 3
quantityForFirstProduct = 5
quantityForSecondProduct = 6
firstProduct = ProductHelper.CreateProduct(firstProductId)
secondProduct = ProductHelper.CreateProduct(secondProductId)
addItemRequests = []
addItemRequest1 = AddItemArgument(firstProduct, quantityForFirstProduct)
addItemRequest2 = AddItemArgument(secondProduct, quantityForSecondProduct)
quote.AddItemsInBulk(addItemRequests)

Creating new Quote revisions

Python
quote = context.Quote
newQuote = quote.CreateNewRevision(True)
newQuote.Comment = 'This is active revision'
newQuote.Save()
newQuote.Revision.SetDescription('Revision description set from scripting')

Submiting Quote for Approval

Python
quote = context.Quote
brokenApprovalRules = quote.GetApprovalConditions();
submitForApprovalRequests = [brokenApprovalRule.ToSubmitForApprovalRequest([responsibleApprover.Id for responsibleApprover in brokenApprovalRule.ResponsibleApprovers], 'Submited for approval from scripting') for brokenApprovalRule in brokenApprovalRules]
quote.SubmitForApproval(submitForApprovalRequests)

Approving Quote

Python
quote = context.Quote
requestsForApproval = quote.GetApproverRequests()
approvalResponse = [approvalRequest.ToApprovalResponse('Approved from scripting') for approvalRequest in requestsForApproval]
quote.Approve(approvalResponse)

Rejecting Quote

Python
quote = context.Quote
requestsForApproval = quote.GetApproverRequests()
approvalResponse = [approvalRequest.ToApprovalResponse('Rejected from scripting') for approvalRequest in requestsForApproval]
quote.Reject(approvalResponse)
Public interfaceIQuote2SectionItemCollectionFor Quote 2.0 only.
Public interfaceIQuoteAffectedItemCollectionFor Quote 2.0 only.
Represents the collection of items that are changed

Example of custom calculation for product type level totals

Python
Trace.Write("Executing ProductType_CustomExtendedAmount custom calculation")
productTypes = context.Quote.ProductTypes
for item in context.AffectedItems:
    Trace.Write("Item id:{} ProductTypeId: {} Delta = {}".format(item.Id, item.ProductTypeId, item.GetDelta("CustomExtendedAmount")))
    productType = next((x for x in productTypes if x.ProductTypeId == item.ProductTypeId), None)
    if productType is not None:
        Trace.Write("Found matching product type")
        if productType["CustomExtendedAmount"] is None:
            Trace.Write("CustomExtendedAmount has NULL value")
            productType["CustomExtendedAmount"] = 0
        productType["CustomExtendedAmount"] += item.GetDelta("CustomExtendedAmount")

Changing Quote Status to specified Quote Status

Python
context.Quote.ChangeStatus("Preparing")
Public interfaceIQuoteAffectedProductTypesCollectionFor Quote 2.0 only.
Public interfaceIQuoteAffectedSectionFor Quote 2.0 only.
Affected quote sections
Public interfaceIQuoteAffectedSectionsCollectionFor Quote 2.0 only.
Public interfaceIQuoteAttachedDocumentFor Quote 2.0 only.
Attached document
Public interfaceIQuoteContextFor Quote 2.0 only.
Public interfaceIQuoteContractDurationBase Contract duration interface.
Public interfaceIQuoteContractExtension The quote contract extension model.
Public interfaceIQuoteCustomerFor Quote 2.0 only.
Quote customer
Public interfaceIQuoteCustomFieldFor Quote 2.0 only.
Represents a quote custom field

Print the Quote Custom field properties

Python
def TraceCustomField(customField):
    Trace.Write("------------------------------------------------")
    Trace.Write("AccessLevel: {}".format(customField.AccessLevel))
    Trace.Write("AttributeValue: {}".format(customField.AttributeValue))
    Trace.Write("AttributeValueCode: {}".format(customField.AttributeValueCode))
    Trace.Write("AttributeValueTranslated: {}".format(customField.AttributeValueTranslated))
    Trace.Write("CustomFieldType: {}".format(customField.CustomFieldType))
    Trace.Write("Label: {}".format(customField.Label))
    Trace.Write("Value: {}".format(customField.Value))
customField = context.Quote.GetCustomField("CustomFieldName")
TraceCustomField(customField)
Public interfaceIQuoteGeneratedDocumentFor Quote 2.0 only.
Generated document
Public interfaceCode exampleIQuoteHelper Allows global manipulations of the Quotes.
Example

Create a new Quote

Python
quote = quoteHelper.CreateNewQuote()

Reassign Quote to specified user

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

Delete Quote

Python
quoteInfo = QuoteHelper.Delete(quoteNumber)

Gets the Quote

Python
quote = QuoteHelper.Get(quoteNumber)
quote.Comment = 'Some Quote Comment'
quote.Save()
Public interfaceIQuoteInfo Result from executing an action on the Quote
Public interfaceIQuoteInvolvedPartyFor Quote 2.0 only.
Public interfaceIQuoteItemFor Quote 2.0 only.
Represent abstract class which expose common interface for main and line items

Different ways to access Quote Item Custom Fields

Python
quoteItem = context.Quote.GetItemByItemNumber(1)
cfValue = quoteItem.GetCustomField("CF name").Value

Another way to acces Quote Item Custom Field Value property is via indexer

Python
cfValue = quoteItem["CF name"]
Public interfaceIQuoteItemAttributeFor Quote 2.0 only.
Quote Item Attribute
Public interfaceIQuoteItemAttributeCollectionFor Quote 2.0 only.
Collection of all attributes selected in product referenced in Quote Item
Public interfaceIQuoteItemAttributeValueFor Quote 2.0 only.
Represents selected value of the attribute of referenced product in Quote Item
Public interfaceIQuoteItemCollectionFor Quote 2.0 only.
Represents collection of quote items
Public interfaceIQuoteItemCustomFieldFor Quote 2.0 only.
Represents a quote item custom field
Public interfaceIQuoteMainItemFor Quote 2.0 only.
Represent abstract class which expose common interface for main items.
Public interfaceIQuoteMessage 
Public interfaceIQuoteProductTypeFor Quote 2.0 only.
Represents a quote product type
Public interfaceCode exampleIQuoteRevisionFor Quote 2.0 only.
Represents a quote revision
Example

Set revision to be active

Python
quoteRevision = context.Quote.Revision
quoteRevision.SetActive()
Public interfaceIQuoteSectionItemFor Quote 2.0 only.
Quote section item
Public interfaceIQuoteShipToCustomerFor Quote 2.0 only.
Quote ship to customer
Public interfaceIQuoteTable Represents custom quote table
Public interfaceIQuoteTableCollection Represents collection of quote tables
Public interfaceIQuoteTotalFor Quote 2.0 only.
Represents a quote total
Public interfaceISavableQuote Represents a IQuote that can be saved manually.
Public interfaceISectionTotalsCollectionFor Quote 2.0 only.
Section Totals Collection
Enumerations
 EnumerationDescription
Public enumerationAccessLevel Represents options of access level
Public enumerationMessageLevel The message level