GlobalAdjustPriceRequest Method
For latest Global Methods, developers should also refer to the corresponding Apex classes in Salesforce for implementation details. The Apex class definitions provide the most accurate, up-to-date method signatures, parameters, and return types, ensuring that any integrations or custom logic are built against the latest release.
To view the class:
- Log in to Salesforce.
- Go to Setup (gear icon → Setup).
- In the Quick Find box, search for and select Developer Console.
- In the Developer Console, open File → Open, then choose the desired Apex Class to review the global methods.
Overview
The GlobalAdjustPriceRequest class provides a comprehensive API for adjusting prices on existing assets through change orders. This class extends the base GlobalAssetChangeRequest and specializes in price modification scenarios including net price changes, discount applications, and true-up pricing adjustments.
Properties
Inherited from GlobalAssetChangeRequest
- assetNumber (String) - The asset number identifying the subscription/product to adjust
GlobalAdjustPriceRequest Properties
- trueUpPrice (Boolean) - Indicates if this is a true-up price adjustment
- netSalesPrice (Decimal) - The new net sales price to apply to the asset
- startDate (Date) - Effective start date for the price adjustment
- endDate (Date) - End date for the price adjustment period
- term (Decimal) - Term length for the adjustment (in months/years as configured)
- discount (DiscountChange) - Discount configuration object
DiscountChange Properties
- discountPercentage (Decimal) - Discount percentage (use 30 for 30%, not 0.3)
- applyToChildren (Boolean) - Whether to cascade discount to child/add-on products
Capabilities
Net Sales Price Adjustments
Example 1
Modify the net sales price of an existing asset subscription.
// Adjust the net sales price of an asset
GlobalAdjustPriceRequest priceRequest = new GlobalAdjustPriceRequest();
priceRequest.assetNumber = 'SUB-00003';
priceRequest.netSalesPrice = 150.00;
priceRequest.startDate = Date.today();
priceRequest.endDate = Date.today().addMonths(12);
priceRequest.term = 12;
priceRequest.trueUpPrice = false;
// Process the price adjustment
// Note: Actual processing would be done through your change order serviceDiscount Applications
Apply percentage-based discounts with optional cascading to child products.
Example 2
// Apply a 25% discount to an asset
GlobalAdjustPriceRequest discountRequest = new GlobalAdjustPriceRequest();
discountRequest.assetNumber = 'SUB-00004';
discountRequest.startDate = Date.today();
discountRequest.endDate = Date.today().addMonths(6);
// Configure discount
GlobalAdjustPriceRequest.DiscountChange discount = new GlobalAdjustPriceRequest.DiscountChange();
discount.discountPercentage = 25; // 25% discount
discount.applyToChildren = true; // Apply to add-on products too
discountRequest.discount = discount;
discountRequest.trueUpPrice = false;True-Up Pricing
Handle true-up scenarios where price adjustments need to be applied retroactively.
Example 3: True-Up Price Adjustment
// Handle a true-up pricing scenario
GlobalAdjustPriceRequest trueUpRequest = new GlobalAdjustPriceRequest();
trueUpRequest.assetNumber = 'SUB-00005';
trueUpRequest.netSalesPrice = 200.00;
trueUpRequest.startDate = Date.today().addMonths(-3); // Retroactive
trueUpRequest.endDate = Date.today();
trueUpRequest.trueUpPrice = true; // Mark as true-up
trueUpRequest.term = 3;Other use-cases:
Example 4: Combined Price and Discount Adjustment
// Adjust both net price and apply discount
GlobalAdjustPriceRequest combinedRequest = new GlobalAdjustPriceRequest();
combinedRequest.assetNumber = 'SUB-00014';
combinedRequest.netSalesPrice = 180.00;
combinedRequest.startDate = Date.today();
combinedRequest.endDate = Date.today().addYears(1);
combinedRequest.term = 12;
// Add discount configuration
GlobalAdjustPriceRequest.DiscountChange discount = new GlobalAdjustPriceRequest.DiscountChange();
discount.discountPercentage = 15; // 15% discount on the new price
discount.applyToChildren = false; // Only apply to main product
combinedRequest.discount = discount;
combinedRequest.trueUpPrice = false;Example 5: Bulk Price Adjustments
// Process multiple price adjustments
List<GlobalAdjustPriceRequest> priceAdjustments = new List<GlobalAdjustPriceRequest>();
// Asset 1: Price increase
GlobalAdjustPriceRequest request1 = new GlobalAdjustPriceRequest();
request1.assetNumber = 'SUB-00008';
request1.netSalesPrice = 250.00;
request1.startDate = Date.today().addMonths(1);
request1.endDate = Date.today().addMonths(13);
request1.term = 12;
// Asset 2: Discount application
GlobalAdjustPriceRequest request2 = new GlobalAdjustPriceRequest();
request2.assetNumber = 'SUB-00009';
request2.startDate = Date.today();
request2.endDate = Date.today().addMonths(6);
GlobalAdjustPriceRequest.DiscountChange bulkDiscount = new GlobalAdjustPriceRequest.DiscountChange();
bulkDiscount.discountPercentage = 20;
bulkDiscount.applyToChildren = true;
request2.discount = bulkDiscount;
priceAdjustments.add(request1);
priceAdjustments.add(request2);
// Process all adjustments
// Implementation would depend on your change order processing serviceExample 6: Price Adjustment for Specific Date Range
// Adjust price for a specific promotional period (Q4 discount)
GlobalAdjustPriceRequest dateRangeRequest = new GlobalAdjustPriceRequest();
dateRangeRequest.assetNumber = 'SUB-00010';
dateRangeRequest.netSalesPrice = 120.00; // Reduced price for promotion
// Set specific date range for the adjustment
dateRangeRequest.startDate = Date.newInstance(2024, 10, 1); // October 1st
dateRangeRequest.endDate = Date.newInstance(2024, 12, 31); // December 31st
// Calculate term in months for the date range
Integer monthsBetween = dateRangeRequest.startDate.monthsBetween(dateRangeRequest.endDate);
dateRangeRequest.term = monthsBetween;
dateRangeRequest.trueUpPrice = false;
// Optional: Add additional discount for the promotional period
GlobalAdjustPriceRequest.DiscountChange promoDiscount = new GlobalAdjustPriceRequest.DiscountChange();
promoDiscount.discountPercentage = 10; // Additional 10% off during promo
promoDiscount.applyToChildren = true;
dateRangeRequest.discount = promoDiscount;Example 7: Term-Based Adjustment with Future Start Date
// Adjust pricing for a 24-month term starting 3 months from now
GlobalAdjustPriceRequest termBasedRequest = new GlobalAdjustPriceRequest();
termBasedRequest.assetNumber = 'SUB-00023';
termBasedRequest.netSalesPrice = 300.00; // New price for extended term
// Set future start date (e.g., when current contract expires)
termBasedRequest.startDate = Date.today().addMonths(3); // Start in 3 months
termBasedRequest.term = 24; // 24-month term
// Calculate end date based on term
termBasedRequest.endDate = termBasedRequest.startDate.addMonths(Integer.valueOf(termBasedRequest.term));
termBasedRequest.trueUpPrice = false;
// Example: Provide volume discount for longer term commitment
GlobalAdjustPriceRequest.DiscountChange volumeDiscount = new GlobalAdjustPriceRequest.DiscountChange();
volumeDiscount.discountPercentage = 5; // 5% discount for 24-month commitment
volumeDiscount.applyToChildren = false; // Apply only to main product
termBasedRequest.discount = volumeDiscount;Integration Patterns
With Change Order Processing
// Example integration with change order service
public class PriceAdjustmentService {
public static void processPriceAdjustment(GlobalAdjustPriceRequest request) {
// Validate the request
validatePriceRequest(request);
// Create change order options
GlobalChangeOrderOptions options = new GlobalChangeOrderOptions(
GlobalChangeOrderProceedOption.CreateDraftOrder
);
// Process through change order system
// Your implementation would call the appropriate service
// Example: ChangeOrderService.processAssetChange(request, options);
}
private static void validatePriceRequest(GlobalAdjustPriceRequest request) {
if (String.isBlank(request.assetNumber)) {
throw new IllegalArgumentException('Asset number is required');
}
if (request.startDate == null) {
throw new IllegalArgumentException('Start date is required');
}
if (request.netSalesPrice != null && request.netSalesPrice < 0) {
throw new IllegalArgumentException('Net sales price cannot be negative');
}
if (request.discount != null &&
(request.discount.discountPercentage < 0 || request.discount.discountPercentage > 100)) {
throw new IllegalArgumentException('Discount percentage must be between 0 and 100');
}
}
}Best Practices
1. Date Validation
- Always validate that startDate is not null
- Ensure endDate is after startDate when both are provided
- Consider business rules for retroactive adjustments when using trueUpPrice = true
2. Price Validation
- Validate that netSalesPrice is positive when provided
- Consider minimum price thresholds based on business rules
- Validate discount percentages are between 0 and 100
3. Asset Number Validation
- Ensure the asset number exists and is active
- Verify user permissions to modify the specific asset
- Check that the asset is in a state that allows price adjustments
4. Discount Cascading
- Use applyToChildren = true carefully, as it affects all child products
- Consider the impact on bundle pricing when cascading discounts
- Document business rules for when child discounts should be applied
5. True-Up Scenarios
- Use trueUpPrice = true only for legitimate retroactive adjustments
- Ensure proper approval workflows for true-up pricing
- Consider revenue recognition implications
Error Handling
public class PriceAdjustmentException extends Exception {}
public static void handlePriceAdjustment(GlobalAdjustPriceRequest request) {
try {
// Validation
if (request == null) {
throw new PriceAdjustmentException('Price adjustment request cannot be null');
}
// Process the adjustment
processPriceAdjustment(request);
} catch (Exception e) {
// Log the error
System.debug(LoggingLevel.ERROR, 'Price adjustment failed: ' + e.getMessage());
// Re-throw with context
throw new PriceAdjustmentException('Failed to process price adjustment for asset ' +
request?.assetNumber + ': ' + e.getMessage());
}
}Limitations and Considerations
- Asset State: Price adjustments may only be possible on assets in certain states
- Approval Requirements: Significant price changes may require approval workflows
- Revenue Recognition: Consider accounting implications of retroactive price changes
- Integration Dependencies: Requires proper integration with change order processing system
- Permissions: Users must have appropriate permissions to modify asset pricing
- Business Rules: Implementation should enforce organization-specific pricing rules
Related Classes
- GlobalAssetChangeRequest - Base class for all asset change requests
- GlobalAssetChangeType - Enum defining available change types (includes AdjustPrice)
- GlobalChangeOrderOptions - Configuration options for change order processing
- GlobalChangeOrderProceedOption - Options for how to proceed with change orders