This API is used to get the unique list of categories for all the products within the specified price list.

APISignature
getCategoriesForPriceListwebService static Apttus_CPQApi.CPQ.CategorySearchResultDO getCategoriesForPriceList(Id priceListId)


Parameters
NameTypeRequired?Description
priceListIdIDYesThe id of the price list


Response Data Object - Apttus_CPQApi.CPQ.CategorySearchResultDO
FieldTypeDescription
CategoriesList<Apttus_CPQApi.CPQ.CategoryDO>The list of category data objects.
HasCategoriesBooleanIndicates if there are categories for the price list.


Data Object - Apttus_CPQApi.CPQ.CategoryDO
FieldTypeDescription
CategoryIdIDThe Id of the category.
ChildCategoriesList<Apttus_CPQApi.CPQ.CategoryDO>The list of child category data objects associated with the category.
HasChildCategoriesBooleanIndicates if the category has child categories.
NameStringThe category name.
ParentCategoryIdIDThe Id of the parent category.
ProductCountIntegerThe number of products within a category.


Code Sample

The code sample below enables you to search for categories based on the pricelist ID. All the categories and subcategories associated with the price list are displayed. You can search for categories associated with a price list till the nth level. You can provide a search field on the cart page that enables the user to search for products by categories. For example, your cart page has multiple categories, such as Laptop, camera, Desktop, Accessories and so on. The user should be able to search for products by category by entering category name such as laptop. Use this API to invoke the categories and its associated sub-categories of products and then display it to the user.
 

public void executeSearch() 
{
//Query for fetching pricelist id by querying price list name           
     List<Apttus_Config2__PriceList__c> priceListItemList = [select id 
     from Apttus_Config2__PriceList__c 
     where  name = :priceListName limit 1];
     
//If an id is returned in the list execute the getCategoriesforpricelist API.            
      if(priceListItemList.size() > 0)
		{
			priceListId = priceListItemList[0].ID;                  
            Apttus_CPQApi.CPQ.CategorySearchResultDO result = Apttus_CPQApi.CPQWebService.getCategoriesForPriceList(priceListId);
			lstwrap = New List<CategoryWrapperClass>();
            For( Apttus_CPQApi.CPQ.CategoryDO catresult : result.Categories)
			{
				CategoryWrapperClass wrap = New CategoryWrapperClass();
                wrap.CategoryId = catresult.CategoryId;
                wrap.categoryName = catresult.name;
                lstwrap.add(wrap);
				//If a category has sub categories fetch the sub-category name and id                                             
				if(catresult.HasChildCategories)
                {
					For( Apttus_CPQApi.CPQ.CategoryDO subcatresult : catresult.ChildCategories)
                    {
						CategoryWrapperClass subwrap = New CategoryWrapperClass();
                        subwrap.CategoryId = subcatresult.CategoryId;
                        subwrap.categoryName = subcatresult.name;
                        lstwrap.add(subwrap);
						// If the sub category has child categories fetch the sub category name and ID.
						if(subcatresult.HasChildCategories)
						{
							For( Apttus_CPQApi.CPQ.CategoryDO subsubcatresult : subcatresult.ChildCategories)
							{
								CategoryWrapperClass subsubwrap = New CategoryWrapperClass();
								subsubwrap.CategoryId = subsubcatresult.CategoryId;
								subsubwrap.categoryName = subsubcatresult.name;
								lstwrap.add(subsubwrap);
							}
						}
					}   
				}
           }
		}
	//If no Price List exists with the searched string name execute the else condition
	else
	{
		lstwrap = New List<CategoryWrapperClass>();
		ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.info, 'Category Name not found. Please enter valid Category Name.'));    
    }
}
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.

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>00DZ000000NAEIA!ASAAQN7k3xhhvMe.j.8gpR.ijcGq77HJeF4MEDfbxbBAqZ8r4WWNTv3OVb6o1bjtHJLbq5mvHcuAH_ie6sTC3DzrWgnLdUuD</cpq:sessionId>
        </cpq:SessionHeader>
    </soapenv:Header>
    <soapenv:Body>
        <cpq:getCategoriesForPriceList>
            <cpq:priceListId>a1DZ0000002mg5n</cpq:priceListId>
        </cpq:getCategoriesForPriceList>
    </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"
    xmlns:CategorySearchResultDO="http://soap.sforce.com/schemas/class/Apttus_CPQApi/CPQ"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <getCategoriesForPriceListResponse>
            <result>
                <CategorySearchResultDO:Categories>
                    <CategorySearchResultDO:CategoryId>a0nZ0000003x6pLIAQ</CategorySearchResultDO:CategoryId>
                    <CategorySearchResultDO:HasChildCategories>false</CategorySearchResultDO:HasChildCategories>
                    <CategorySearchResultDO:Name>Auto_API_Category</CategorySearchResultDO:Name>
                    <CategorySearchResultDO:ParentCategoryId xsi:nil="true"/>
                    <CategorySearchResultDO:ProductCount>15</CategorySearchResultDO:ProductCount>
                </CategorySearchResultDO:Categories>
                <CategorySearchResultDO:HasCategories>true</CategorySearchResultDO:HasCategories>
            </result>
        </getCategoriesForPriceListResponse>
    </soapenv:Body>
</soapenv:Envelope>
XML