Customizing the Cart Checkout page
Users see the Cart Checkout page on the new My Cloud Services console just before submitting their requests for services.
By default, this page includes two fields: Charge Code (which specifies the cost center to charge for the services) and Decommission Date. You can customize this page to remove these field or show other fields from customized AR System forms or an external system. This topic outlines how to add and remove fields in these sections:
- Before you begin
- To remove the Charge Code and Decommission Date fields
- To add fields to the Cart Checkout page (beginner)
- To add fields to the Cart Checkout page that retrieve data from external systems (advanced)
- Related topics
The following video (6:02) describes how you can customize the Cart Checkout page of the My Cloud Services console.
Before you begin
- Verify that your configuration specifies the default location property of the custom directory.
For example: com.bmc.cloud.ui.custom.resource.dir=installDirectory/custom
If the property is missing and not properly configured, you will not see your changes. Add this property with your custom directory as the value if it is missing. Depending on how you installed the My Cloud Services console (clmui), verify that the custom directory is set:- If you installed the My Cloud Services console (clmui) on its own host, open the Config.properties file (by default /opt/bmc/CloudPortalWebApplication/tomcat/webapps/clmui/WEB-INF/classes or C:\Program Files\BMC Software\CloudPortalWebApplication\tomcat\webapps\clmui\WEB-INF\classes).
You should see the following property and value:
com.bmc.cloud.ui.custom.resource.dir=installDirectory\\Cloud_UI\\custom
For example:
com.bmc.cloud.ui.custom.resource.dir=/opt/bmc/CloudPortalWebApplication/Cloud_UI/custom (Linux)
com.bmc.cloud.ui.custom.resource.dir=C:\\Program Files\\BMC Software\\CloudPortalWebApplication\\Cloud_UI\\custom (Windows) - If you did not install the My Cloud Services console (clmui) on its own host but on the Platform Manager host, open the cloudservices.json file (by default C:\Program Files\BMC Software\BMCCloudLifeCycleManagement\Platform_Manager\configuration\cloudservices.json).
In the CustomDir section, you should see the attributeValue property whose value is the custom directory:{
"cloudClass" : "com.bmc.cloud.model.beans.AccessAttribute",
"datatype" : "String",
"description" : "Directory that contains customization web content",
"guid" : "780a47aa-d6a9-4894-9aa5-a5fa2ce26cb1",
"hasValueObject" :
[
{
"cloudClass" : "com.bmc.cloud.model.beans.AccessAttributeValue",
"attributeValue" : "C:\\Program Files\\BMC Software\\BMCCloudLifeCycleManagement\\Cloud_UI\\custom",
"guid" : "8b03984d-7750-4ba2-a8f7-8f7ef48fb43d",
"name" : "CustomDir"
}
],
"isOptional" : true,
"isPassword" : false,
"modifiableWithoutRestart" : false,
"name" : "CustomDir"
}
- If you installed the My Cloud Services console (clmui) on its own host, open the Config.properties file (by default /opt/bmc/CloudPortalWebApplication/tomcat/webapps/clmui/WEB-INF/classes or C:\Program Files\BMC Software\CloudPortalWebApplication\tomcat\webapps\clmui\WEB-INF\classes).
- Copy the contents of the installDirectory\Cloud_UI\custom_sample directory to the installDirectory\Cloud_UI\custom directory on the My Cloud Services Console host.
- When you add resource or angular files for your locale, make sure that the encoding in your editor is set to Unicode (UTF-8). Otherwise, your text might be corrupted.
To remove the Charge Code and Decommission Date fields
In the CLMInstallationFolder/Cloud_UI/custom/cart/views/customFieldsTemplate.html file, comment out or remove the sections related to Charge Code and Decommission Date fields (as needed).
For example, if you comment out the text as shown below, you will hide the Charge Code field:<!--
<div class="cart_cost-center">
<label class="cart_cost-label" ng-bind="'customfields.label.chargecode' | i18n"></label>
<div class="input-group btn-group">
<input type="text" class="form-control" ng-model="customFieldsNameValueMap.costCenter">
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
<ul id="customfields_costcenter-menu" class="dropdown-menu dropdown-menu-right" role="menu">
<li ng-repeat="item in costCenterItems" class="input-lg"><a href="" ng-bind="item.code ? item.code + ' - ' + item.name : item.code" ng-click="setCostCenterSelectedItem(item.code)"></a></li>
</ul>
</div>
</div>
</div>
-->- If you want to hide the Decommission Date field, complete the following steps in addition to step 1:
- Open the CLMInstallationFolder/Cloud_UI/custom/cart/scripts/customFieldsController.js file.
Modify the $scope.doValidation() method by commenting out or removing the decommissionDate related code.
The modified code should look something like this:$scope.doValidation = function() {
// Do the field validation here
var checkFlag = true;
/*
var decommissionDateValue;
if (angular.element($("#decommissionDateField"))[0].value != "") {
// enable manually typed in date for FF and IE
decommissionDateValue = Date.parse(angular.element($("#decommissionDateField"))[0].value);
if (decommissionDateValue == null) {
$scope.showDecommissionDateErrorMsg = true;
checkFlag = false;
} else {
var d = new Date();
if ((new Date(d.getFullYear(), d.getMonth(), d.getDate())).getTime() > decommissionDateValue.getTime()) {
$scope.showDecommissionDateErrorMsg = true;
checkFlag = false;
}
}
if (checkFlag) {
$scope.showDecommissionDateErrorMsg = false;
}
} else {
$scope.showDecommissionDateErrorMsg = false;
}
$scope.customFieldsNameValueMap["decommissionDate"] = angular.element($("#decommissionDateField"))[0].value;
*/
customFieldsService.isValidated.flag = checkFlag;
return checkFlag;
};
- To see that the fields were removed, flush the cache in your browser and add a request to the cart.
To add fields to the Cart Checkout page (beginner)
The following example shows how to add two text fields, Confidentiality and Visibility, on the Cart Checkout page. Even though text fields are used in this example, you could use drop-down fields with values populated (hard-coded in the HTML/javascript) so that the user can select a value rather than typing it in.
- Stop the Platform Manager.
- If the CLMInstallationFolder\Cloud_UI\custom folder is empty, copy the contents of the custom_sample folder to the custom folder.
These directories are in one of two places:- CLMInstallationFolder/BMCSoftware/BMCCloudLifecycleManagement/Cloud_UI (if you installed the Cloud Portal Web Application as part of your BMC Cloud Lifecycle Management installation)
- CLMInstallationFolder/BMCSoftware/CloudPortalWebApplication/Cloud_UI (if you installed the Cloud Portal Web Application separately from your BMC Cloud Lifecycle Management installation)
- Add the new fields to the Cart Checkout user interface:
- Open the custom/cart/views/customFieldsTemplate.html file for editing.
Add the following code snippet:
Place the <div> snippet to the same level as Cost Center and Decommission Date.<div>
<label for="confidentiality_id" ng-bind="'customfields.label.confidentiality' | i18n"></label>
<input type="text" id="confidentiality_id" name="confidentiality" ng-model="customFieldsNameValueMap.confidentiality">
<label for="visibility_id" ng-bind="'customfields.label.visibility' | i18n"></label>
<input type="text" id="visibility_id" name="visibility" ng-model="customFieldsNameValueMap.visibility">
</div>- Save and close the customFieldsTemplate.html file.
- (Optional) In a text editor, open the CLMInstallationFolder/Cloud_UI/custom/cart/scripts/customFieldsController.js file for editing. This file is used for validation and other logic related to the new field.
Locate the validation section of the file:
////////////////////////////////////////////////////////////////////////////////////////////////////////
// Modify the following part for customization
////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Validate all the custom fields
* @returns {boolean} true if valid, false otherwise
*/
$scope.doValidation = function() {
// Do the field validation here
return true;
};Modify the doValidation method to validate each custom field. For example, to make the Application ID field required enter the following code:
if ($scope.customFieldsNameValueMap.confidentiality == "")
return false;
else
return true;- Save and close the customFieldsController.js file.
- Prepare the localization files for the new fields:
- In a text editor, open the CLMInstallationFolder/Cloud_UI/custom/i18n/resources-locale_en.js file for editing.
- Add code that maps the field's key to a label value that is displayed in the Cart.
Add localized strings for the labels:
{
"key" : "customfields.label.confidentiality",
"value" : "Confidentiality"
},
{
"key": "customfields.label.visibility",
"value": "Visibility"
}- Save and close the resources-locale_en.js file.
- Add the metadata for these two fields in the BMC_CLM_Install_folder/Platform_Manager/configuration/customField/metadata.json file.
- On the machine where Platform Manager is installed, open the BMC_CLM_Install_folder/Platform_Manager/configuration/customField/metadata.json file for editing.
Add lines for your new fields. For example:
{
"fieldName": "confidentiality",
"localizationKey": "customfields.label.confidentiality",
"dataType": "string"
},
{
"fieldName": "visibility",
"localizationKey": "customfields.label.visibility",
"dataType": "string"
}- Save and close the metadata.json file.
- Restart the Platform Manager.
Flush the cache in your browser and add a request to the Cart.
When you open the Cart Checkout page, you can now see these two new fields - Confidentiality and Visibility – are present. The values entered in these fields will be saved at the backend after you submit the cart. Those values will then be displayed in the service and server details screens after provisioning.
To add fields to the Cart Checkout page that retrieve data from external systems (advanced)
If you want to customize the new My Cloud Services console and retrieve data from an external system, you must use a web service or RESTful APIs.
- If the CLMInstallationFolder/Cloud_UI/custom folder is empty, copy the contents of the custom_sample folder to the custom folder.
These directories are in one of two places:- CLMInstallationFolder/BMCSoftware/BMCCloudLifecycleManagement/Cloud_UI (if you installed the Cloud Portal Web Application as part of your BMC Cloud Lifecycle Management installation)
CLMInstallationFolder/BMCSoftware/CloudPortalWebApplication/Cloud_UI (if you installed the Cloud Portal Web Application separately from your BMC Cloud Lifecycle Management installation)
- Add the new field to the Cart Checkout user interface:
- Open the custom/cart/views/customFieldsTemplate.html file for editing.
- Add a field in the file as you want it to appear in the custom fields section of the Cart Checkout page.
- Save and close the customFieldsTemplate.html file.
- Provide metadata for the new field. This is used primarily to obtain the localization key , and to know whether the field should be indexed.
- On the machine where Platform Manager is installed, open the BMC_CLM_Install_folder/Platform_Manager/configuration/customField/metadata.json file for editing.
Add lines for your new field. For example:
{
"fieldName": "appid",
"localizationKey": "customfields.label.appid",
"dataType": "String"
}- Save and close the metadata.json file.
- Restart the Platform Manager.
- In a text editor, open the CLMInstallationFolder/Cloud_UI/custom/cart/scripts/customFieldsController.js file for editing. This file is used for validation and other logic related to the new field.
Locate the validation section of the file:
////////////////////////////////////////////////////////////////////////////////////////////////////////
// Modify the following part for customization
////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Validate all the custom fields
* @returns {boolean} true if valid, false otherwise
*/
$scope.doValidation = function() {
// Do the field validation here
return true;
};Modify the doValidation method to validate each custom field. For example, to make the Application ID field required enter the following code:
if ($scope.customFieldsNameValueMap.appId == "")
return false;
else
return true;- Save and close the customFieldsController.js file.
Prepare the localization files for the new field as follows:
- In a text editor, open the CLMInstallationFolder/Cloud_UI/custom/i18n/resources-locale_en.js file for editing.
Add code that maps the field's key to a label value that is displayed in the Cart. For example, the mapping for the Application ID field is already present in the file and merely needs to be uncommented:
{
"key": "customfields.label.appid",
"value": "Application ID"
}- Save and close the resources-locale_en.js file.
- If needed, repeat this series of steps for other language files in the i18n folder.
- If you have defined additional JavaScript or CSS files to be used in conjunction with your new field, specify those files in the customResourcesToInclude.txt file:
In a text editor, open the CLMInstallationFolder/Cloud_UI/custom/customResourcesToInclude.txt file for editing.
Add a new line for the file to be used by your new field. For example, uncomment the following line to reference a JavaScript file to be used by the new appid field:
<script type="text/javascript" src="custom/cart/scripts/arWebserviceClient.js"></script>- Save and close the customResourcesToInclude.txt file.
- If you want to add new functionality related to the new field (such as a webservice call), update the custom\cart\scripts\customFieldsService.js file.
- Restart the Platform Manager.
The new field appears on the Cart Checkout page.
To complete the Application ID example with a back-end AR form and AR web service
The preceding procedure included an example that added an Application ID field to the Cart Checkout page. This drop-down field contains no information unless it has a source from which to retrieve that information. In this section, the example is expanded to create a BMC Remedy AR System form to contain the data, and an BMC Remedy AR System web service to call the data on behalf of the new custom field.
- Create a new BMC Remedy AR System form, as described in Creating-forms.
- Name the form SAMPLE:ApplicationId.
- Set the permission of the form to Public.
- In the form, add a character field named Application ID.
- Set the permission of the field to Public.
- Open the form, and create entries with the following Application ID field values:
- Collaboration Team
- Data Services
- Enterprise Development
- Mobile Applications
- Create a basic BMC Remedy AR System web service, as described in Creating-a-basic-web-service.
Name the web service SAMPLE_ApplicationId_Service.
The WSDL of the web service will be structured as http://midtierServer/arsys/WSDL/public/serverName/SAMPLE_ApplicationId_Service. Enable cross-domain requests for the Mid Tier.
For Tomcat version 7.0.41 and later, add the following lines to the ARSystemFolder\midtier\WEB-INF\web.xml file, and then restart the Mid Tier:
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>- For Tomcat versions earlier than 7.0.41, CORS is not supported, and you must use a different mechanism:
- Download and enable CORS.
For example, see http://software.dzhuvinov.com/cors-filter.html. - Extract the cors-filter-version.jar and java-property-utils-version.jar files to the ARSystemFolder\midtier\WEB-INF\lib folder.
Add the following lines to the ARSystemFolder/midtier/WEB-INF/web.xml file, and then restart the Mid Tier:
<filter>
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
- Download and enable CORS.
Related topics
Adding-custom-panels-or-sections-to-the-Catalog-service-details-page