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;
}