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.
Charges are not standalone sellable items.
Use
addProducts(...)oraddProductsInInterval(...)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 |
|---|---|---|---|
| timelineId | string | Yes | Target product timeline id. |
| chargeInput | object | object[] | { charge?: object, charges?: object[] } | Yes | One 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 |
|---|---|---|---|
| intervalId | number | string | object | Yes | Interval index, interval start date, or interval object. |
| timelineId | string | Yes | Target product timeline id. |
| chargeInput | object | object[] | { charge?: object, charges?: object[] } | Yes | One 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 |
|---|---|---|---|
| timelineId | string | Yes | Target product timeline id. |
| chargeIdOrKey | string | Yes | Charge id, preview charge id, or product rate plan charge id. |
| patch | object | Yes | Field 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 |
|---|---|---|---|
| intervalId | number | string | object | Yes | Interval index, interval start date, or interval object. |
| timelineId | string | Yes | Target product timeline id. |
| chargeIdOrKey | string | Yes | Charge id, preview charge id, or product rate plan charge id. |
| patch | object | Yes | Field updates for the charge. |
updateChargeField(timelineId, chargeIdOrKey, fieldName, value)
Signature:
updateChargeField(
timelineId: string,
chargeIdOrKey: string,
fieldName: string,
value: any
): CustomEvent
Parameter | Type | Required | Description |
|---|---|---|---|
| timelineId | string | Yes | Target product timeline id. |
| chargeIdOrKey | string | Yes | Charge id, preview charge id, or product rate plan charge id. |
| fieldName | string | Yes | Exact charge field API name. |
| value | any | Yes | Value 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 |
|---|---|---|---|
| intervalId | number | string | object | Yes | Interval index, interval start date, or interval object. |
| timelineId | string | Yes | Target product timeline id. |
| chargeIdOrKey | string | Yes | Charge id, preview charge id, or product rate plan charge id. |
| fieldName | string | Yes | Exact charge field API name. |
| value | any | Yes | Value to assign. |
removeCharge(timelineId, chargeIdOrKey)
Signature:
removeCharge(
timelineId: string,
chargeIdOrKey: string
): CustomEvent
Parameter | Type | Required | Description |
|---|---|---|---|
| timelineId | string | Yes | Target product timeline id. |
| chargeIdOrKey | string | Yes | Charge 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 |
|---|---|---|---|
| intervalId | number | string | object | Yes | Interval index, interval start date, or interval object. |
| timelineId | string | Yes | Target product timeline id. |
| chargeIdOrKey | string | Yes | Charge 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)
);