Conga Product Documentation

Welcome to the new doc site. Some of your old bookmarks will no longer work. Please use the search bar to find your desired topic.

Removing Products from Hierarchy

You can use this API to remove a product from a category.

API

Signature

removeProductFromHierarchy

webService static Apttus_Config2.CPQAdminStruct.HierarchyResponseDO removeProductFromHierarchy(Apttus_Config2.CPQAdminStruct.HierarchyRequestDO hierarchyRequestDO)

Request Parameter

Name

Type

Description

hierarchyRequestDO Apttus_Config2.CPQAdminStruct.HierarchyRequestDO

The category request data object.

Request Parameter - Apttus_Config2.CPQAdminStruct.HierarchyRequestDO

Name Type

Description

HierarchyDOs List<Apttus_Config2.CPQAdminStruct.HierarchyDO>

The list of hierarchy data object

Data Object- Apttus_Config2.CPQAdminStruct.HierarchyDO

Name

Type

Description

ChildProductId Id

The Id of child product.

ParentProductId Id

The Id of the parent product.

Response Data Object- Apttus_Config2.CPQAdminStruct.HierarchyResponseDO

Name

Type

Description

Issuccess Boolean

Indicates whether the removal of the product from the hierarchy.

Code Sample

The below sample code enables you to remove the products from their relevant category.

/**
 * The below code removes the products from category. Invoke below method by passing parent and child product names.
 * Remove a child product from a hierarchy of a parent product.
 * The input request contains the Child Product Id and the Parent Product Id.
 * In case a list of products is passed, this will be an all-or-none scenario stored in 
 * the single Boolean return value.
 */

public Boolean removeProductFromHierarchy(String parentProductName, String childProductName) 
{
	Apttus_Config2.CPQAdminStruct.HierarchyDO hierDO = new Apttus_Config2.CPQAdminStruct.HierarchyDO();
	Apttus_Config2.CPQAdminStruct.HierarchyRequestDO hierRequest = new Apttus_Config2.CPQAdminStruct.HierarchyRequestDO();
	Apttus_Config2.CPQAdminStruct.HierarchyResponseDO removeResponse = null;

	// STEP 1 - Retrieve data
	// get child, parent products, and option group
	Product2 parentProduct = [SELECT Id 
			           FROM Product2 
			           WHERE Name = :parentProductName 
							  LIMIT 1];
	Product2 childProduct = [SELECT Id 
			        FROM Product2 
			        WHERE Name = :childProductName 
			        LIMIT 1];

	// STEP 2 - Remove child from hierarchy
	// build request object		
	hierDO = new Apttus_Config2.CPQAdminStruct.HierarchyDO();
	hierDO.ParentProductId = parentProduct.Id;
	hierDO.ChildProductId = childProduct.Id;
	hierDO.ParentOptionGroupId = null;
	hierDO.ChildOptionGroupId = null;
	// add hierarchy DO to request
	hierRequest.HierarchyDOs.add(hierDO);

	// send request for removal and save response
	removeResponse = Apttus_Config2.CPQAdminWebService.removeProductFromHierarchy(hierRequest);
	return removeResponse.Issuccess;
}