ABP API
Info
Use this API to run Attribute Based Pricing in your code (eg. for investigating problems). As params pass your pricing step parameters (from Pricing Plan Step).
Run attribute based pricing for: OrderItem, QuoteLineItem, OpportunityLineItem
Get attribute based pricing result for all items in quote
List<SObject> items = [SELECT Id, vlocity_cmt__LineNumber__c, PricebookEntry.Product2.ProductCode, PricebookEntry.Product2.Name, vlocity_cmt__AssetReferenceId__c, vlocity_cmt__ParentItemId__c, vlocity_cmt__RootItemId__c, vlocity_cmt__JSONAttribute__c, vlocity_cmt__AttributeSelectedValues__c, vlocity_cmt__AttributeMetadataChanges__c, PricebookEntry.Product2.vlocity_cmt__AttributeMetadata__c FROM QuoteLineItem WHERE QuoteId='...'];
Map<String,Object> params = new Map<String,Object>{'MatrixName'=>'AttributePricingMatrix',
'Source Product Code'=>'PricebookEntry.Product2.ProductCode',
'Source Product Name'=>'PricebookEntry.Product2.Name' };
Map<String,Object> result = sfix.AttributeBasedPricing.getCaclulationMatrixOutput( params, items );
System.debug(JSON.serialize(result));
Run attribute based pricing for: Asset
Get attribute based pricing result for all assets in account
List<SObject> items = [SELECT Id, vlocity_cmt__LineNumber__c, Product2.ProductCode, Product2.Name, vlocity_cmt__AssetReferenceId__c, vlocity_cmt__ParentItemId__c, vlocity_cmt__RootItemId__c, vlocity_cmt__JSONAttribute__c, vlocity_cmt__AttributeSelectedValues__c, vlocity_cmt__AttributeMetadataChanges__c, Product2.vlocity_cmt__AttributeMetadata__c FROM Asset WHERE AccountId = '...'];
Map<String,Object> params = new Map<String,Object>{'MatrixName'=>'AttributePricingMatrix',
'Source Product Code'=>'Product2.ProductCode',
'Source Product Name'=>'Product2.Name' };
Map<String,Object> result = sfix.AttributeBasedPricing.getCaclulationMatrixOutput( params, items );
System.debug(JSON.serialize(result));
ABP Performance Considerations
- If you want to track detailed SFIX execution logs wrap your code in following:
sfix.DebugLogger.setLogging(true); ... SfixLogWrapper.printDebugLog(); - For V2 Attributes avoid parsing attribute JSON in Product2 object by using attribute values (not attribute value labels) in pricing matrices. Use corresponding
UseDisplayTextForValuesvalue in ABP parametes:“UseDisplayTextForValues” : “False”
- For V1 Attributes you can avoid parsing attribute JSON in line item by providing attribute value map as additional input parameter (make sure
UseDisplayTextForValuesis false):List<SObject> items = [SELECT Id, SomeCustomField__c, vlocity_cmt__LineNumber__c, Product2.ProductCode, Product2.Name, vlocity_cmt__AssetReferenceId__c, vlocity_cmt__ParentItemId__c, vlocity_cmt__RootItemId__c, vlocity_cmt__JSONAttribute__c, vlocity_cmt__AttributeSelectedValues__c, vlocity_cmt__AttributeMetadataChanges__c, Product2.vlocity_cmt__AttributeMetadata__c FROM Asset WHERE AccountId = '...']; Map<String,Map<String,Object>> itemAttributeMap = new Map<String,Map<String,Object>>(); for( SObject item : items ) itemAttributeMap.put( item.Id, new Map<String,Object>{'ATT_SOME_ATTRIBUTE'=>item.get('SomeCustomField__c')} ); Map<String,Object> params = new Map<String,Object>{'MatrixName'=>'PRB2BAttributePricingMatrix', 'Source Product Code'=>'Product2.ProductCode', 'Source Product Name'=>'Product2.Name' 'UseDisplayTextForValues'=>'False'}; Map<String,Object> result = sfix.AttributeBasedPricing.getCaclulationMatrixOutput( params, items, itemAttributeMap );