This associates constraints rules to a cart.


APISignature
associateConstraintRuleswebService static void associateConstraintRules(Id cartId, List existingPrimaryNumbers)
Parameters
NameTypeDescription
cartIdIDThe id of the cart.
existingPrimaryNumbersList<Integer>This is a collection of primary numbers for which rules are already attached. When existing primary numbers are supplied, rules are associated with the new lines; whereas when null or empty collection is supplied, rules are attached to all the line items.


Code Sample

The sample below enables you to associate a constraint rule to a product added as a line item in a cart. The sample below fetches the line numbers of the products in the cart and associates the constraint rule to the new line numbers of the cart. If the list object for primary line items is null, then the constraint rules are associated with all the products in the line items of the cart. For example if the delivery and packaging charge constraint rule is already applied to the existing products in the cart, you will provide a list of collection of primary line items comprising selected products to which the rules are already applied, thus enabling the delivery and packaging constraint rule to be associated with the new line items added to the cart.


public void associateConstraintRules()
{
   List<Apttus_Config2__LineItem__c> liSOList = [select Apttus_Config2__ProductID__c, 
   Apttus_Config2__LineNumber__c from Apttus_Config2__LineItem__c where 
   Apttus_Config2__ConfigurationId__c = :cartID];
   
   acrList = new List<Apttus_Config2__LineItem__c>();
   
   List<Integer> primaryLines = new List<Integer>();
   for(Apttus_Config2__LineItem__c liSO: liSOList) 
   {
	   for(Apttus_Config2__LineItem__c acrSO: acrList)
	   {
			if(acrSO.Id == liSO.Id)
			{
				primaryLines.Add(liSO.Apttus_Config2__LineNumber__c.intValue());
			}
	   }
   }
   
   for(Apttus_Config2__LineItem__c liSO: liSOList) 
   {
	   for(LineItemWrapperClass objLineItemWrapperClass : lstWrapItems) 
	   {
		   if(objLineItemWrapperClass.Selected)
		   {
			   acrList.add(liSO);
			   break;
		   }               
	   }
   }
   
   Apttus_CPQApi.CPQWebService.associateConstraintRules(cartId, primaryLines);
}
CODE


Integration Details

Use the following information in your integrations with Apttus CPQ Web Services API. Refer to Integrating Apttus with External Systems for information on how to get started.

API Prerequisites

Response/Request XML

Example Request (click to expand)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cpq="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQWebService">
   <soapenv:Header>
      <cpq:SessionHeader>
         <cpq:sessionId>00D4P000000z7dE!AQQAQGL6XYy.QsjqQQ6RTBnh.1ApTbiqkGAdVz9BS70lxobcyXgHHplmGXAe7p_cf6ziWJ8tpQt_4Q4Bi2VtYeMyzjhaPbf0</cpq:sessionId>
      </cpq:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <cpq:associateConstraintRules>
         <cpq:cartId>a1l4P00000Bg6eAQAR</cpq:cartId>
         <!--Zero or more repetitions:-->
         <cpq:existingPrimaryNumbers>1</cpq:existingPrimaryNumbers>
      </cpq:associateConstraintRules>
   </soapenv:Body>
</soapenv:Envelope>
XML

Example Response (click to expand)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQWebService">
   <soapenv:Body>
      <associateConstraintRulesResponse/>
   </soapenv:Body>
</soapenv:Envelope>
XML