Welcome to Zuora Product Documentation

Explore our rich library of product information

Headless component - hooks

Explore the Headless Component in Quote Studio, which allows triggering custom logic through hooks during various events, enhancing the Extensibility Framework.

Introduces Headless Component that can trigger custom component logic upon Quote Studio events.

Headless Component expands the capabilities of the Extensibility Framework Custom Components. With this, you can trigger custom component logic upon Quote Studio events.

From Quotes version 10.21 or later, you can designate components as Headless component without a user interface (UI). These components can be harnessed to execute your extensibility framework custom component logic based on Quote Studio events, specifically save or submit events.

Note that only a single active Headless Component is permissible.
Use as headless component

Headless components allow you to utilize global methods (hooks) to create custom logic. The following are the hooks available in the extensibility framework:

beforeSave

This hook triggers when the Save button is clicked in Quote Studio.

Method nameInput parameterReturn parameterDescription
beforeSaveN/A

Boolean (optional)

(default: true)

Based on the returned boolean value, the save logic is executed.
  • When the returned value is TRUE, Quote Studio continues the logic execution of the save method.
  • When the returned value is FALSE, Quote Studio stops the save method logic.

beforeSubmit

This hook triggers when the Submit, Back, or Save changes and Leave button is clicked in Quote Studio.

Method nameInput parameterReturn parameterDescription
beforeSubmitN/A

Boolean (optional)

(default: true)

Based on the returned boolean value, the submit logic is executed.

  • When the returned value is TRUE, Quote Studio continues the submit method logic execution.
  • When the returned value is FALSE, Quote Studio stops the submit method logic.

beforePreviewCall

This hook triggers the Preview Call in Quote Studio. This is only applicable for Preview on-demand.

Method nameInput parameterReturn parameterDescription
beforePreviewCallN/A

Boolean (optional)

(default: true)

The preview call logic is executed based on the returned boolean value.

  • When the returned value is TRUE, Quote Studio continues the preview call method logic execution.
  • When the returned value is FALSE, Quote Studio stops the preview call method logic.

beforeProductAdd

This hook triggers when the product add button is clicked, executing before the product addition logic runs (before the product is added to the UI).
Note: This hook is executed only when the product is added from UI.

Input:

ParameterTypeValues
newRatePlanMapJS objectObject of Product Rate Plan Ids along with quantities.
effectiveDateStringEffective Date for which Product Rate Plans is added.

Return:

The return type of this hook is JSON object.

ParameterTypeValueDescription
proceedBooleantrueQuote Studio continues the product add logic execution. Send this parameter with other parameters.
falseIf you don't want to proceed with product add logic execution, you can return {proceed: false}.
newRatePlanMapJS objectObject of Product Rate Plan Ids along with quantities. The New Rate Plan Map is to be considered for further processing.

If you proceed with productAdd, you can return:

{proceed: true, newRatePlanMap}

effectiveDate (Optional)StringThe Effective date is to be considered for further processing.

If you proceed with productAdd, you can return:

{proceed: true, newRatePlanMap, effectiveDate}

@api
beforeProductAdd(newRatePlanMap, effectiveDate) {
   //add logic
   return { proceed: true, newRatePlanMap, effectiveDate }
}

afterProductAdd

This hook triggers when the add product button is clicked, executing after the product addition logic runs (after the product is added to the UI).
Note: This hook is executed only when the product is added from UI.

Input:

ParameterTypeValues
newProductTimelineJS objectObject of newly added Product Timelines (Read only - cannot make any updates).

Return:

N/A

Signature:

@api
afterProductAdd(newProductTimeline) {
   //add logic
}

beforeProductUpdate

This hook triggers after making any update on the product (charge, amendment, rate plan, future dated update, revert on future dated update, or revert on future dated - remove), executing before the product update logic.
Note: This hook is executed only when the product is updated from UI.

Input:

ParameterTypeValuesDescription
updatedChargesArrayAn array of objects of updated charge record

For charge update, future dated update, or future dated update - revert, the value is an array of objects representing the updated charge record.

For future dated update - revert, the updated charges contain an array of charges to be reverted.

nullFor amendment update, rate plan update, or future dated remove - revert, the value is null.
updatedAmendmentJS ObjectObject of updated amendment record

For a future dated update, future dated update - revert or future dated remove - revert, the value is an object of updated amendment record.

For future dated update - revert or future dated remove - revert, the updated amendment contains object of amendment record that is to be reverted.

amendmentJS ObjectObject of updated amendment recordFor amendment update, the value is as mentioned in the value column.
specificUpdateDateStringDate used for specific update, if applicable
nullWhen it's a charge update or rate plan update, the value is null.
updatedRatePlan

JS ObjectObject of updated quoteRatePlan record

For rate plan update, future dated update, future dated update - revert or future dated remove - revert, the value is an object of updated Quote Rate Plan record.

For future dated update - revert and future dated remove - revert, the updated rate plan contains object of updated Quote Rate Plan record that is to be reverted.

nullFor charge update or amendment update, the value is null.
isRevertBooleantrueFor future dated update - revert or future dated remove - revert, the value is True.
falseFor charge update, rate plan update, amendment update, or future dated update, the value is False.

Return:

The return type of this hook is JSON object.

ParameterTypeValueDescription
proceedBooleantrueProceeds with product update. Send this parameter along with the other parameters mentioned in this table.
falseIf you do not want to proceed with the product update, you can return {proceed: false}.
updatedChargesArrayAn array of objects of updated charge record to proceed with the updateReturn this parameter for a charge update or future dated update.
updatedAmendmentJS ObjectObject of updated amendment recordReturn this parameter for an amendment update.
updatedAmendmentJS ObjectReturn this parameter for an amendment update.
amendmentJS ObjectObject of updated amendment record to proceed for update
specificUpdateDateStringDate used for the specific update to proceed for update, if applicable
updatedRatePlanJS ObjectObject of updated Quote Rate Plan record to proceed with the updateReturn this parameter for a rate plan update or future dated update.

Return Signatures:

  • For a charge update, Return { updatedCharges, proceed: true | false }
  • For an amendment update, Return { updatedAmendment, proceed: true | false }
  • For a rate plan update, Return { updatedRatePlan, proceed: true | false}
  • For a future dated update, Return { updatedCharges, updatedRatePlan, updatedAmendment, updatedRatePlan, proceed: true | false }
  • For a future dated update - revert, Return { proceed: true }
  • For a future dated remove - revert, Return { proceed: true }

Signature

@api
beforeProductUpdate(updatedCharges, updatedAmendment, updatedRatePlan, isRevert) {
//add logic
return { updatedCharges: [], proceed: true}
}

afterProductUpdate

This hook triggers after making any update on the product like charge, amendment, rate plan, future dated - updates, future dated update - revert, or future dated remove - revert, executing after the product update logic.
Note: This hook is executed only when the product is added from UI.

Input:

ParameterTypeValuesDescription
updatedChargeArrayAn array of objects of updated charge recordFor charge update or future dated update, the value is an array of objects of updated charge record.
nullFor amendment update, rate plan update, future dated update - revert, or future dated remove - revert, the value is null.
updatedRatePlanArrayAn array of product version that was updatedFor charge update, amendment update, rate plan update, or future dated update, the value is an array of product version that was updated.
Remaining versions of product after revertFor a future dated update - revert or future dated remove - revert, the value is an array of remaining versions of product after revert.

Return:

N/A

Signature:

@api
afterProductUpdate(updatedCharge, updatedRatePlan) {
 //add logic
}

beforeRulesExecution

This hook helps to run the custom logic before running the rules. This allows the following functionalities:

  • Filter the rules
  • Skip/run rules execution

The input and return types of this hook are both JSON objects.

In Quotes version 10.37, the following parameters are added to the return type of the hook.

  • forceExecuteRules parameter - You can use this parameter to run the rules regardless of the triggering conditions, Active field status, or other conditions.
  • includeRemovedRatePlan parameter - You can use this parameter to include the future dated remove rate plan in the rules engine.

Signature:

@api
async beforeRulesExecution(context) {
      // Execute the logic
      return {
          rulesToExecute : [],
          runRules : true,
          forceExecuteRules: true,
          includeRemovedRatePlan: true
      }
}

Input:

ParameterTypeValuesDescription
ContextJS ObjectContains execution context data.
triggerEventString

InitialLoad

Everytime

SaveSubmit

Triggering event for the rules in Quote Studio.

Return:

ParameterTypeRequiredValueDescription

rulesToRun

Holds the ZRule Ids

ArrayRequiredEmptyAll the rules are executed.
FilledSpecified list of ZRule Ids are executed.
runRulesBooleanOptionalTrueRules are executed.
FalseRules are skipped.
forceExecuteRulesBooleanOptionalTrueExecutes the selected rules irrespective of triggering conditions, Active field status, or other conditions.
FalseExecute the rules based on the triggering condition and Active field status field.
includeRemovedRatePlanBooleanOptionalTrue

Custom action plugin executes, including future dated remove rate plans.

Quote Rate Plan Charges removed using remove product action are not included in the object structure.

FalseCustom action plugin executes excluding future dated remove rate plans.
Note: If runRules is not provided in the return statement, the default value is true, and the rules engine is executed.

@api pageState contains the rules data if the fields are added to fieldset CPQX Rule Fields on the ZRule__c object.

Rules are listed as active and inactive based on the zqu__Active__c field. If this field is not added to the fieldset by default, all the rules are added to the inactive list.

pageState : {
      rules : {
          active: [],
          inactive: []
      }
  }

Custom Fields

Product Rate Plan fields added to the below fieldset would be available in @api quoteState in the extensibility framework.

ObjectFieldset name
ProductRatePlanCPQX Rules Engine Custom Fields.

Custom Action Plugin:

Product Rate Plan and Product Rate Plan Charge records can be accessed in a custom action plugin.

Product Rate Plan and Product Rate Plan Charge custom fields can be accessed in a custom action plugin when the custom fields are added to the following fieldsets.

ObjectField set name
ProductRatePlan__cCPQX Rules Engine Custom Fields.
ProductRatePlanCharge__cCPQX Rules Engine Custom Fields.

afterRulesExecution

This hook triggers after the rules are executed.

Input:

ParameterTypeValues
rulesResponseJS Object

Contains

Actions [ ] → Actions performed

Messages [ ] → Messages returned from the rule

newlyAddedTimelines { } → product timeline of newly added products as part of rules execution

rulesMatched (Number) → Rules that are matched and executed

success (Boolean) → returns the status of execution

updatedQuoteState { } → Returns the updated quoteState after rules execution.

Return:

N/A

Signature:

@api
afterRulesExecution(rulesResponse) {
//add logic
}

beforeSubmitNavigation

This hook triggers when the submit button is clicked, executing immediately after the submit logic and before redirecting to the next page from Quote Studio.

Return:

ParameterTypeValueDescription
proceed

BooleanTrueProceed with redirection to the next page.
FalseDo not proceed with redirection to the next page.
redirectionURLStringRedirection URL (Optional)This property redirects the page to the given URL. If it is not returned, redirect the page to the default next page.

Signature:

@api
beforeSubmitNavigation() {
   //add logic
   return { proceed: true };
}

afterQuoteUpdate

This hook triggers after making any update on the quote field and executes after the Quote update logic.

Note: This hook is executed only when a quote is changed
ParameterTypeValues
oldQuoteJS ObjectObject of quote record before the quote update.
newQuoteJS ObjectObject of quote record after the quote update.

Signature:

afterQuoteUpdate(oldQuote, newQuote) {
   // add Logic
}

beforeMSQChildSave

This hook executes when the user switches from one child quote to another just before the save logic is executed.

Return:

TypeValueDescription
BooleanTrueProceed with save logic.
FalseDo not proceed with save logic.

Signature

@api
beforeMSQChildSave() {
  //add logic
  return true;
}

beforeProductRemove

This hook executes when the Confirm button is selected within the Future-Dated Remove window and when the Delete button is clicked for a newly added product. It runs prior to the execution of both the Future-Dated Remove and Delete logic.

Input:

ParameterTypeValuesDescription
removedQplanJS ObjectObject of removed qPlanIncludes data for the removed rate plan and amendment.
nullNot a future-dated remove action
deletedTimelineJS ObjectObject of deleted productTimelineIncludes data for the deleted timeline Id, versions, rateplans, amendments and charges.
nullNot a delete product action.
timelineIdStringId of the timelineContains the timeline ID of the future-dated removal or deleted product.

Return:

TypeValuesDescription
BooleantrueProceed with Future-Dated Remove or Product Delete logic.
falseDo not proceed with Future-Dated Remove or Product Delete logic.

Signature:

@api
beforeProductRemove(removedQplan, deletedTimeline, timelineId) {
  //add logic
  return true;
}

For a sample code that uses the hooks mentioned in this article, see Sample code for hooks and events.