Welcome to Zuora Product Documentation

Explore our rich library of product information

Charge helpers

Helpers for adding, updating, and removing charges within an existing quote rate plan timeline.

These helpers operate within an existing quote rate plan context.

Note:
  • Charges are not standalone sellable items.

  • Use addProducts(...) or addProductsInInterval(...) to add a new product / rate plan to the quote.

  • Use the charge helpers only when you are working inside an existing timelineId.

  • In practice, addCharge(...) is appropriate for valid in-plan charge records such as optional or generated charges in an existing quote rate plan.

addCharge(timelineId, chargeInput)

Signature:

addCharge(
    timelineId: string,
    chargeInput: object | object[] | { charge?: object, charges?: object[] }
): CustomEvent

Parameter

Type

Required

Description

timelineIdstringYesTarget product timeline id.
chargeInputobject | object[] | { charge?: object, charges?: object[] }YesOne charge, a list of charges, or an object containing charge/charges to add inside the existing quote rate plan context.

Returns:

  • CustomEvent('updateproducts')

Use this when:

  • the target rate plan already exists in the quote.

  • the charge payload is valid for that existing rate plan context.

Do not use this when:

  • you want to add a brand-new sellable product or rate plan.

  • you do not already have a valid timelineId.

For those cases, use addProducts(...) or addProductsInInterval(...).

Example:

this.dispatchEvent(
    zqf.addCharge(timelineId, {
        record: {
            Name: 'Optional Ramp Charge',
            zqu__ProductRatePlanCharge__c: 'a0R...',
            zqu__Action__c: 'Create',
            zqu__Optional__c: true
        }
    })
);

addChargeInInterval(intervalId, timelineId, chargeInput)

Signature:

addChargeInInterval(
    intervalId: number | string | object,
    timelineId: string,
    chargeInput: object | object[] | { charge?: object, charges?: object[] }
): CustomEvent

Parameter

Type

Required

Description

intervalIdnumber | string | objectYesInterval index, interval start date, or interval object.
timelineIdstringYesTarget product timeline id.
chargeInputobject | object[] | { charge?: object, charges?: object[] }YesOne or more charges to add inside the existing quote rate plan context for the specified interval.

updateCharge(timelineId, chargeIdOrKey, patch)

Signature:

updateCharge(
    timelineId: string,
    chargeIdOrKey: string,
    patch: object
): CustomEvent

Parameter

Type

Required

Description

timelineIdstringYesTarget product timeline id.
chargeIdOrKeystringYesCharge id, preview charge id, or product rate plan charge id.
patchobjectYesField updates for the charge.

Example:

this.dispatchEvent(
    zqf.updateCharge(timelineId, chargeIdOrKey, {
        zqu__Quantity__c: 7,
        zqu__Discount__c: 15
    })
);

updateChargeInInterval(intervalId, timelineId, chargeIdOrKey, patch)

Signature:

updateChargeInInterval(
    intervalId: number | string | object,
    timelineId: string,
    chargeIdOrKey: string,
    patch: object
): CustomEvent

Parameter

Type

Required

Description

intervalIdnumber | string | objectYesInterval index, interval start date, or interval object.
timelineIdstringYesTarget product timeline id.
chargeIdOrKeystringYesCharge id, preview charge id, or product rate plan charge id.
patchobjectYesField updates for the charge.

updateChargeField(timelineId, chargeIdOrKey, fieldName, value)

Signature:

updateChargeField(
    timelineId: string,
    chargeIdOrKey: string,
    fieldName: string,
    value: any
): CustomEvent

Parameter

Type

Required

Description

timelineIdstringYesTarget product timeline id.
chargeIdOrKeystringYesCharge id, preview charge id, or product rate plan charge id.
fieldNamestringYesExact charge field API name.
valueanyYesValue to assign.

updateChargeFieldInInterval(intervalId, timelineId, chargeIdOrKey, fieldName, value)

Signature:

updateChargeFieldInInterval(
    intervalId: number | string | object,
    timelineId: string,
    chargeIdOrKey: string,
    fieldName: string,
    value: any
): CustomEvent

Parameter

Type

Required

Description

intervalIdnumber | string | objectYesInterval index, interval start date, or interval object.
timelineIdstringYesTarget product timeline id.
chargeIdOrKeystringYesCharge id, preview charge id, or product rate plan charge id.
fieldNamestringYesExact charge field API name.
valueanyYesValue to assign.

removeCharge(timelineId, chargeIdOrKey)

Signature:

removeCharge(
    timelineId: string,
    chargeIdOrKey: string
): CustomEvent

Parameter

Type

Required

Description

timelineIdstringYesTarget product timeline id.
chargeIdOrKeystringYesCharge id, preview charge id, or product rate plan charge id.

Use this to remove an existing charge from a quote rate plan in the current context.

removeChargeInInterval(intervalId, timelineId, chargeIdOrKey)

Signature:

removeChargeInInterval(
    intervalId: number | string | object,
    timelineId: string,
    chargeIdOrKey: string
): CustomEvent

Parameter

Type

Required

Description

intervalIdnumber | string | objectYesInterval index, interval start date, or interval object.
timelineIdstringYesTarget product timeline id.
chargeIdOrKeystringYesCharge id, preview charge id, or product rate plan charge id.

Use this to remove an existing charge from a quote rate plan in a specific ramp interval.

Example:

this.dispatchEvent(
    zqf.removeChargeInInterval(1, timelineId, chargeIdOrKey)
);