Checking if Product Exists in Hierarchy
You can use this API to check if a product exist in a category.
API |
Signature |
---|---|
productExistsInHierarchy |
webService static Apttus_Config2.CPQAdminStruct.HierarchyResponseDO productExistsInHierarchy(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 product exists in the hierarchy or not. |
Code Sample
The below sample code finds whether the child product is available in the hierarchy of its parent product.
public Boolean productExistsInHierarchy(String parentProductName, String childProductName)
{
Apttus_Config2.CPQAdminStruct.HierarchyDO hierDO = new Apttus_Config2.CPQAdminStruct.HierarchyDO();
Apttus_Config2.CPQAdminStruct.HierarchyRequestDO hierRequest = null;
Apttus_Config2.CPQAdminStruct.HierarchyResponseDO hierResponse = null;
// 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];
hierRequest = new Apttus_Config2.CPQAdminStruct.HierarchyRequestDO();
hierDO = new Apttus_Config2.CPQAdminStruct.HierarchyDO();
hierDO.ParentProductId = parentProduct.Id;
hierDO.ChildProductId = childProduct.Id;
hierRequest.HierarchyDOs.add(hierDO);
hierResponse = Apttus_Config2.CPQAdminWebService.productExistsInHierarchy(hierRequest);
return hierResponse.Issuccess;
}