Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
maxLevel1

Generic Logic

Create a generic feeder logic that emits the Quote objects for use in the Analytics logic:

Paste code macrocode
languagegroovy
def quotesRecieved = true
int i = 0
int step = 200
def qs = []
def quotes = []
while (quotesRecieved) {
  // lastRunTime - last run time of the Data Load. For the first run, it should be an old date which includes all the quotes.
  qs = api.find("Q", i, step, null,
                Filter.greaterOrEqual("lastUpdateDate", lastRunTime))
  if (qs.size() != 0) {
    quotes += qs
    i += step
  } else {
    quotesRecieved = false
  }
}

for (q in quotes) {
  if (q?.id != null) api.emitPersistedObject("Q", q.id)
}

Analytics Logic

Retrieve the target rowset from the Datamart:

paste-code-macro
languagegroovy
def targetRs = api.getDatamartRowSet("target")

Fetch the Quote from the feeder logic:

paste-code-macro
languagegroovy
def quotetargetRs = api.currentItemgetDatamartRowSet("target")

Fetch header inputs/output values from the Quote:

paste-code-macro
languagegroovy
def clic = api.getCalculableLineItemCollection(quote?.typedId)
for (input in clic?.inputs) {
  if (input.name == "OpportunityType") {
    opptyType = input.value
    continue
  }    
}

for (output in clic?.outputs) {
  if (output.resultName == "Country") {
    country = output.result
    continue
  } 
}

Fetch line-level inputs/output values from the Quote (you can use api.getCalculableLineItemResult to fetch line-level outputs):

paste-code-macro
languagegroovy
for (li in clic.lineItems) {
  def lineId = li.lineId 
  def cli = api.getCalculableLineItem(clic.typedId, lineId)
	for (input in cli?.inputs) {
      if (input.name == "Apply Quantity Break Pricing Structure") {
        applyQtyBreak = input.value
        continue
      }
  }
  def tierDiscount = api.getCalculableLineItemResult(cli, "TierDiscount")
}

Create a map object mapping values to Datamart fields. (Map keys MUST match the Datamart field names). Add the row to the target rowset:

paste-code-macro
languagegroovy
def row = [:]
row.Quote = quote.uniqueName
row.CustomerNumber = customerNum
row.CustomerName = customerName
row.NationalAccount = nationalAcct

targetRs?.addRow(row)

Create global variables for all field values:

paste-code-macro
languagegroovy
row?.each {
    api.global[it.key] = it.value
}

...