Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If you need to pass Quote, Contract or Rebate Agreement header field values to the inline configurator logic, you can use the api.contextTypedId() method. This way, you can obtain the TypedId and further work with it (e.g., fetch a Quote).

An example could be a requirement to pass to and read in the configurator logic if a Rebate Agreement is a revision of the original version. An element in the Configurator logic would look like this:

Paste code macro
languagegroovy
def id = api.contextTypedId()
if (id) {
  def rba = api.getCalculableLineItemCollection(id)
  if (rba.prevRev) {
    return true
  }
}
return false

This example gets the Quote status and makes the input field non-editable if the Quote status is not Draft:

titleContract Header Logic
if (api.isSyntaxCheck())
   return

def configuratorValue = cProcessor.getHelper().getRoot().getInputByName("configurator")?.value

cProcessor.addOrUpdateInput("ROOT",
		["name" : "configurator",
		"label" : "Configuration",
		"type" : "INLINECONFIGURATOR",
		"typedId" : api.contextTypedId(),
		"url" : "PromotionManagerConfigurator",
		"value" : configuratorValue]
		)


if (api.isSyntaxCheck()) return
Paste code macro
languagegroovy
titlePromotionManager Configurator Logic
def typedId = api.input("typedId")

def configuratorcontract = api.createConfiguratorEntry()
def entry = configurator.find("CT", Filter.equal("id", typedId?.split('\\.')[0]))[0]

//Description
def descriptionParam = ce.createParameter(InputType.STRINGUSERENTRY,"Description")
"Test")
def quote = api.find(api.contextType(), Filter.equal("id", api.contextTypedId().split('\\.')[0]))[0]
def quoteStatus = quote.get('quoteStatus')

if (quoteStatus != 'DRAFT') {
	entry.readOnly = true  
}
return configuratordescriptionParam.setLabel("Description")
descriptionParam.setReadOnly(true)
descriptionParam.setValue(contract.get("label"))
descriptionParam.setParameterGroup("General")

//Start Date
def startDateParam = ce.createParameter(InputType.DATEUSERENTRY,"StartDate")
startDateParam.setLabel("Start Date")
startDateParam.setReadOnly(true)
startDateParam.setParameterGroup("General")
def startDate = api.input("StartDate")
if(!startDate)
	startDate = contract.get("startDate")
startDateParam.setValue(startDate)

//Upload Customers
def uploadCustomersParam = ce.createParameter(InputType.PARSABLEINPUTFILE,"UploadCustomers")
uploadCustomersParam.setTypedId(contract.typedId)
uploadCustomersParam.setLabel("Upload Customer(s)")
uploadCustomersParam.setParameterGroup("Upload Customer(s)")
def uploadCustomers = api.input("UploadCustomers")
uploadCustomersParam.setValue(uploadCustomers)