Skip to main content

Remote Calls with JavaScript Plugin


Remote Calls with JavaScript Plugin

This article presents a sample code for using JavaScript remoting with the Product Selector JavaScript plugin.

The Visualforce page and the controller define a remote action, GetInfo, which is a server-side method that can be called from JavaScript. And the JavaScript plugin calls that and updates the charge in the callback.

MyCpqSelectProductController Controller

public with sharing class MyCpqProductSelectorController {

  public zqu.SelectProductComponentOptions theOptions { get; set; }
  public MyCpqProductSelectorController(ApexPages.StandardController controller){
    theOptions = new zqu.SelectProductComponentOptions();
    theOptions.mode = zqu.SelectProductComponentOptions.MODE_EDIT;
    theOptions.quoteId = controller.getId();
  public static Map<String, Object> getInfo() {
      return new Map<String, Object> {
          'newPrice' => 99.99

MyCpqSelectProduct Page

<apex:page sidebar="false" tabStyle="zqu__Quote__c" standardController="zqu__Quote__c" extensions="MyCpqProductSelectorController">
    var asyncGetPrice = function(callback) {
        function(result, event) {
  <apex:form >
    <zqu:CpqSelectProduct options="{!theOptions}"/>

ProductSelectorPlugin JavaScript Plugin

var ProductSelectorPlugin = {
    postRecalculateZCharge : function(previousZCharge,
      currentZCharge, chargeGroup, quote, allChargeGroups) {
      console.log('Request info for:');
      asyncGetPrice(function(result) {
        console.log('Received info:');
        currentZCharge['EFFECTIVE_PRICE'] = result.newPrice.toString();