Loading
Connect in real time with the Trailblazer Community in Slack Open BetaRead More
Get Started with Communications, Media, and Energy & Utilities (CME)...
MSApplyToGroupInterface:shouldRegenerateRefNums Method

MSApplyToGroupInterface:shouldRegenerateRefNums Method

Determines whether a discount reference number should be regenerated or copied over.

Interface

Class

Signature

public Boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options)

Usage

This method is used in the multi-site ApplyToGroup process. For each member of a group, this method returns a Boolean value that determines whether a discount reference number should be regenerated or copied over.

Parameters

Parameter

Data Type

Description

input

Map

Map <String, Object> of the required input parameters for the method.

output

Map

Map <String, Object> to store the result value.

option

Map

Map <String, Object> of the optional input parameters for the method.

methodName

String

The name of the method that you want to use. In this case: shouldRegenerateRefNums

Input Data

Here's an example of the input data for this method.

{
	"discounts": [{
		"attributes": {
			"type": "vlocity_cmt__QuoteDiscount__c",
			"url": "/services/data/v49.0/sobjects/vlocity_cmt__QuoteDiscount__c/a4y3h000000aTeqAAE"
		},
		"Id": "a4y3h000000aTeqAAE",
		"Name": "SEPT TEST FLAT 30% OFF",
		"vlocity_cmt__Action__c": "New",
		"vlocity_cmt__AppliesToAllItems__c": true,
		"vlocity_cmt__ApprovalStatus__c": "Approved",
		"vlocity_cmt__DiscountTemplateId__c": "a3B3h000000lMf2EAE",
		"vlocity_cmt__DiscountType__c": "Order",
		"vlocity_cmt__DurationUnitOfMeasure__c": "Month",
		"vlocity_cmt__QuoteId__c": "0Q03h000000MrNlCAK",
		"vlocity_cmt__Status__c": "Not Activated",
		"vlocity_cmt__ReferenceNumber__c": "12d1f9af-b8a1-2a97-645c-0e2493857f1c",
		"vlocity_cmt__QuoteDiscountPricing__r": {
			"totalSize": 1,
			"done": true,
			"records": [{
				"attributes": {
					"type": "vlocity_cmt__QuoteDiscountPricing__c",
					"url": "/services/data/v49.0/sobjects/vlocity_cmt__QuoteDiscountPricing__c/a4x3h000000hL8dAAE"
				},
				"vlocity_cmt__QuoteDiscountId__c": "a4y3h000000aTeqAAE",
				"Id": "a4x3h000000hL8dAAE",
				"Name": "a3B3h000000lMf2EAE",
				"vlocity_cmt__AdjustmentValue__c": 30.00,
				"vlocity_cmt__Amount__c": 0.00,
				"vlocity_cmt__PricingVariableId__c": "a2v3h000000eYQDAA2"
			}]
		}
	}, {
		"attributes": {
			"type": "vlocity_cmt__QuoteDiscount__c",
			"url": "/services/data/v49.0/sobjects/vlocity_cmt__QuoteDiscount__c/a4y3h000000aTevAAE"
		},
		"Id": "a4y3h000000aTevAAE",
		"Name": "CustomDisc",
		"vlocity_cmt__Action__c": "New",
		"vlocity_cmt__AppliesToAllItems__c": true,
		"vlocity_cmt__ApprovalStatus__c": "Approved",
		"vlocity_cmt__DiscountType__c": "Account",
		"vlocity_cmt__DurationUnitOfMeasure__c": "Month",
		"vlocity_cmt__Duration__c": 1.0,
		"vlocity_cmt__QuoteId__c": "0Q03h000000MrNlCAK",
		"vlocity_cmt__Status__c": "Not Activated",
		"vlocity_cmt__ReferenceNumber__c": "9779017c-49b3-1d3e-395f-615f4d89ebe9",
		"vlocity_cmt__QuoteDiscountPricing__r": {
			"totalSize": 1,
			"done": true,
			"records": [{
				"attributes": {
					"type": "vlocity_cmt__QuoteDiscountPricing__c",
					"url": "/services/data/v49.0/sobjects/vlocity_cmt__QuoteDiscountPricing__c/a4x3h000000hL8iAAE"
				},
				"vlocity_cmt__QuoteDiscountId__c": "a4y3h000000aTevAAE",
				"Id": "a4x3h000000hL8iAAE",
				"Name": "a4y3h000000aTevAAE",
				"vlocity_cmt__AdjustmentValue__c": -10.00,
				"vlocity_cmt__PricingVariableId__c": "a2v3h000000sqxZAAQ"
			}]
		}
	}],
	"memberId": "a2o3h000000GdVKAA0",
	"memberType": {
		"attributes": {
			"type": "vlocity_cmt__CpqMemberType__mdt",
			"url": "/services/data/v49.0/sobjects/vlocity_cmt__CpqMemberType__mdt/m063h000000ijdjAAA"
		},
		"DeveloperName": "Premises",
		"Id": "m063h000000ijdjAAA",
		"Label": "Premises",
		"Language": "en_US",
		"MasterLabel": "Premises",
		"NamespacePrefix": "vlocity_cmt",
		"QualifiedApiName": "vlocity_cmt__Premises",
		"vlocity_cmt__DisplaySequence__c": 2,
		"vlocity_cmt__IsActive__c": true,
		"vlocity_cmt__MemberObjectName__c": "vlocity_cmt__Premises__c",
		"vlocity_cmt__OrderFieldName__c": "vlocity_cmt__DefaultPremisesId__c",
		"vlocity_cmt__OrderItemFieldName__c": "vlocity_cmt__PremisesId__c",
		"vlocity_cmt__OrderMemberFieldName__c": "vlocity_cmt__PremisesId__c",
		"vlocity_cmt__QuoteFieldName__c": "vlocity_cmt__DefaultPremisesId__c",
		"vlocity_cmt__QuoteLineItemFieldName__c": "vlocity_cmt__PremisesId__c",
		"vlocity_cmt__QuoteMemberFieldName__c": "vlocity_cmt__PremisesId__c"
	}
}

Output Data

Here's an example of the output data returned by this method.

{
  "shouldRegenerateRefs": {
    "a4y3h000000aTevAAE": true,
    "a4y3h000000aTeqAAE": true
  },
  "errorCode": "INVOKE-200",
  "error": "OK"
}

Example

Here's a sample implementation that uses this method.

global class CustomMSApplyToGroupImpl implements vlocity_cmt.VlocityOpenInterface {
  public Boolean invokeMethod(String methodName, Map < String, Object > input, Map < String, Object > output, Map < String, Object > options) {
    if (methodName.equals('shouldRegenerateRefNums')) {
      shouldRegenerateRefNums(input, output);
      return true;
    }
    return false;
  }

  /*
   * Returns discountId => boolean flag in shouldRegenerateRefs map
   */
  private void shouldRegenerateRefNums(Map < String, Object > input, Map < String, Object > output) {
    Map < Id, Boolean > result = new Map < Id, Boolean > ();
    List < SObject > discounts = (List < SObject > ) input.get('discounts');
    Id memberId = (Id) input.get('memberId');
    vlocity_cmt__CpqMemberType__mdt memberType = (vlocity_cmt__CpqMemberType__mdt) input.get('memberType');
    for (SObject disc: discounts) {
      Boolean flag = true;
      // Write your logic to set the flag
      result.put((Id) disc.get('Id'), flag);
    }
    output.put('shouldRegenerateRefs', result);
  }
}
 
Loading
Salesforce Help | Article