Associating Constraint Rule to Products Added to the Cart
You can use this API to execute constraint rules on a list of products.
API |
Signature |
---|---|
associateConstraintRulesForProducts |
webService static Boolean associateConstraintRulesForProducts(Id cartId, List productIds) |
Parameters |
||
---|---|---|
Name |
Type |
Description |
cartId | Id |
The Id of the cart you added products to. |
productIds | List<Id> |
The list of Ids of the products you added to the cart. |
Response Parameter |
||
---|---|---|
Field |
Type |
Description |
IsSuccess | Boolean |
Indicates whether the association was successful. |
Code Sample
The sample below enables you to executes a constraint rule on a list of line items in the given cart.
public Boolean associateConstraintRules(String proposalID)
{
Apttus_Config2__ProductConfiguration__c cart = [SELECT Apttus_Config2__PriceListId__c, Id
FROM Apttus_Config2__ProductConfiguration__c
WHERE Apttus_QPConfig__Proposald__c =: proposalID
LIMIT 1];
//Fetch All products from Product Configuration
List<Apttus_Config2__LineItem__c> liSOList = [SELECT Apttus_Config2__ProductID__c
FROM Apttus_Config2__LineItem__c
WHERE Apttus_Config2__ConfigurationId__c = :cart.Id];
List<Id> productIds = new List<Id> ();
for (Apttus_Config2__LineItem__c liSO: liSOList)
{
productIds.add(liSO.Apttus_Config2__ProductID__c);
}
Boolean isSuccess = Apttus_Config2.ConstraintWebService2.associateConstraintRulesForProducts(cart.Id, productIds);
return isSuccess;
}