PDF
Download PDF
Download page Creating Favorite Configuration.
Creating Favorite Configuration
This API creates a favorite configuration from the Catalog page referenced by cartID.
API | Signature |
---|---|
saveFavoriteConfiguration | static Apttus_Config2.FavoriteConfigurationStruct.SaveFavoriteResponseDO saveFavoriteConfiguration(Apttus_Config2.FavoriteConfigurationStruct.SaveFavoriteRequestDO requestDO) |
Parameters | ||
---|---|---|
Name | Type | Description |
request | Apttus_Config2.FavoriteConfigurationStruct.SaveFavoriteRequestDO | The request data object. |
Request Data Object - Apttus_Config2.FavoriteConfigurationStruct.SaveFavoriteRequestDO | ||
---|---|---|
Field | Type | Description |
cartID | ID | The identifier of the cart. |
favoriteConfigurationSO | Apttus_Config2__FavoriteConfiguration__c | Reference to the Favorite Configuration Object |
lineNumbers | List <Integer> | The list of line numbers to be added to the favorite configuration. |
Response Data Object - Apttus_Config2.FavoriteConfigurationStruct.SaveFavoriteResponseDO | ||
---|---|---|
Field | Type | Description |
favoriteConfigurationSO | Apttus_Config2__FavoriteConfiguration__c | Reference to the Favorite Configuration Object |
processedLineNumbers | List<Integer> | List of line numbers added as a favorite configuration. |
Data Object - Apttus_Config2__FavoriteConfiguration_c | ||
---|---|---|
Field | Type | Description |
Name | String | Enter a suitable name for your favorite configuration. This name is displayed as a record under your Favorites category. |
PriceListId | String | The pricelist id associated with a favorite configuration. |
Scope | String | Choose an option for the visibility of your configuration record. The available values are, Public and Private. If you set this to Private, this record is visible to only the owner of the record. If you set this to Public, this record is accessible to all the users. |
Code Sample
The sample below enables you to create a favorite configuration for a cart with a cartId. You can invoke this API in use cases when you want to show a Favorite configuration page based on the cartID and pricelist.
public class QAddToFavorite implements Queueable {
public Apttus_Config2.FavoriteConfigurationStruct.SaveFavoriteRequestDO requestDO;
public QAddToFavorite(Apttus_Config2.FavoriteConfigurationStruct.SaveFavoriteRequestDO requestDO)
{
this.requestDO = requestDO;
}
public void execute(QueueableContext context)
{
Apttus_Config2.FavoriteConfigurationStruct.SaveFavoriteResponseDO responseDO = new Apttus_Config2.FavoriteConfigurationStruct.SaveFavoriteResponseDO();
responseDO = Apttus_Config2.FavoriteConfigurationGlobalService.saveFavoriteConfiguration(requestDO);
List<Integer> processedLineNumbers = responseDO.processedLineNumbers;
List<Integer> unProcessedLineNumbers = new List<Integer>();
for (Integer lineNumber : requestDO.lineNumbers)
{
if (!processedLineNumbers.contains(lineNumber))
{
unProcessedLineNumbers.add(lineNumber);
}
}
if (!unProcessedLineNumbers.isEmpty())
{
requestDO.favoriteConfigurationSO.id = responseDO.favoriteConfigurationSO.id ;
requestDO.lineNumbers = unProcessedLineNumbers;
system.debug('Request DO is ' + requestDO);
System.enqueueJob(new QAddToFavorite(requestDO));
}
}
}
//Sample code to execute from the anonymous window.
Apttus_Config2.FavoriteConfigurationStruct.SaveFavoriteRequestDO requestDO = new Apttus_Config2.FavoriteConfigurationStruct.SaveFavoriteRequestDO();
requestDO.favoriteConfigurationSO.Name = 'QueueableAPI-1 Fav BundleandStd'; // Name of favorite configuration
requestDO.favoriteConfigurationSO.Apttus_Config2__Active__c = true;
requestDO.favoriteConfigurationSO.Apttus_Config2__Scope__c = 'Public';
requestDO.favoriteConfigurationSO.Apttus_Config2__PriceListId__c = 'a4QP0000000wNyC'; // priceList ID
requestDO.favoriteConfigurationSO.Apttus_Config2__Description__c = 'Sample description';
requestDO.cartId = ID.valueOf('a4jP0000000M23t'); // product configuration or cartID
requestDO.lineNumbers = new List<Integer>{1,2,3,4,5,6,7,8,9,10};
System.enqueueJob(new QAddToFavorite(requestDO));
CODE