33 Making Notes Field Mandatory

This chapter describes how to make the Notes field mandatory for additional product purchase and event adjustments.

To make the Notes field mandatory, see the following:

Making Notes Mandatory for Additional Product Purchase

You can make the Notes field on the Purchase Add on Deal Confirmation screen mandatory by customizing the screen using the Billing Care SDK.

To make the Notes field mandatory:

  1. Create a custom view model to override the default view of the Purchase Add on Deal Confirmation screen. See "Creating a Custom Purchase Deal View Model" for more information.

  2. Create a customRegistry.js file to configure Billing Care to use the custom view model that you created. See "Configuring the Custom Purchase View Model in the Registry" for more information.

  3. Deploy your customizations using one of the methods described in "Using an Exploded Archive during Customization" or "Packaging and Deploying Customizations".

Creating a Custom Purchase Deal View Model

Billing Care uses view model to define the display of the screens in Billing Care. You must create or update the custom view model, CustomPurcahseViewModel, and add the details containing the logic to make the Notes field mandatory.

See "About View Models" for more information about Billing Care view models.

To create a custom purchase deal view model:

  1. Create or update the customPurchaseViewModel.js file in myproject/web/custom/viewmodels directory, where myproject is the folder containing your NetBeans IDE project.

  2. Add the following code in the customPurchaseViewModel.js file using a text editor:

    define(['jquery', 'knockout', 
    'viewmodels/purchase/PurchaseConfigurationViewModel'], 
            function ($, ko, PurchaseConfigurationViewModel) { 
    
                function CustomPurchaseViewModel() { 
                    PurchaseConfigurationViewModel.apply(this, arguments); 
                    self = this; 
                     
                    self.isValid = function () { 
                         $("#enterNotesTextArea").attr('name', 
    'enterNotesWithoutReason'); 
                        if (self.note.isValid() && self.note.validator && 
    self.note.validator.form() && self.note.comments.comment() ) { 
                            return true; 
                        } 
                        return false; 
                    }; 
                } 
                CustomPurchaseViewModel.prototype = new 
    PurchaseConfigurationViewModel(); 
                return  CustomPurchaseViewModel; 
            }); 
    
  3. Save the file in your NetBeans IDE project.

Configuring the Custom Purchase View Model in the Registry

After creating the required custom view model, create a custom purchase view model entry in the customRegistry.js file. Billing Care uses the custom purchase view model instead of the default view model during additional product purchase and renders the Purchase Add on Deal Confirmation screen containing your customization.

To create the custom purchase view model entry in the registry:

  1. Create a customRegistry.js file in myproject/web/custom/ directory.

  2. Define the custom event adjustment module in this file. For example:

    purchaseConfiguration: { 
           viewmodel: 'custom/viewmodels/customPurchaseViewModel.js' 
       } 
    
  3. Save the file in your NetBeans IDE project.

Making Notes Mandatory for Event Adjustments

You can make the Notes field in the Event Adjustment dialog box mandatory by customizing the dialog box using the Billing Care SDK.

To make the Notes field mandatory:

  1. Create a custom view model to override the default view of the Event Adjustment dialog box. See "Creating a Custom Event Adjustment View Model" for more information.

  2. Create a customRegistry.js file to configure Billing Care to use the custom view model that you created. See "Configuring the Custom Event Adjustment View Model in the Registry" for more information.

  3. Deploy your customizations using one of the methods described in "Using an Exploded Archive during Customization" or "Packaging and Deploying Customizations".

Creating a Custom Event Adjustment View Model

Billing Care uses view model to define the display of the screens in Billing Care. You must create or update the custom view model, CustomEventAdjustmentViewModel, and add the details containing the logic to make the Notes field mandatory.

See "About View Models" for more information about Billing Care view models.

To create the custom event adjustment view model:

  1. Create the customEventAdjustmentViewModel.js file in myproject/web/custom/viewmodels directory, where myproject is the folder containing your NetBeans IDE project.

  2. Add the following code in the customEventAdjustmentViewModel.js file using a text editor:

    define(['jquery', 'knockout', 
        'viewmodels/ARActions/adjustments/EventAdjustmentViewModel' 
    ], 
            function($, ko, EventAdjustmentViewModel) { 
                function customViewModel() { 
                    EventAdjustmentViewModel.apply(this, arguments); 
                    self = this; 
                    self.isValid = function() { 
    
         /** 
                         * Here "if(isGranted)" condition is added for authorization. 
         * create customAction in resource and use it in below function 
         * util.isGrantedResourceAction("customAction", "NoteResource"); 
         * 
         * Use below line directly without "if(isGranted)" condition if OES 
    enforcement is not needed 
                 * $("#enterNotesTextArea").attr('name', 
    'enterNotesWithoutReason'); 
                          * 
                         */ 
                        var isGranted = 
    util.isGrantedResourceAction("customAction", "NoteResource"); 
                        if (isGranted) { 
                            $("#enterNotesTextArea").attr('name', 
    'enterNotesWithoutReason'); 
                        } 
                        if (self.note.isValid() && self.validator && 
    self.validator.form()) { 
                            return true; 
                        } 
                        return false; 
                    }; 
                } 
                customViewModel.prototype = new EventAdjustmentViewModel(); 
                return  customViewModel; 
            }); 
    
  3. Save the file in your NetBeans IDE project.

Configuring the Custom Event Adjustment View Model in the Registry

After creating the required custom view model, create a custom event adjustment model entry in the customRegistry.js file. Billing Care uses the custom event adjustment view model instead of the default event adjustment view model during adjustments and renders the Event Adjustment dialog box containing your customization.

To create the custom event adjustment module entry in the registry:

  1. Create a customRegistry.js file in myproject/web/custom/ directory.

  2. Define the custom event adjustment module in this file. For example:

    eventAdjustment: { 
           viewmodel: 'custom/viewmodels/customEventAdjustmentViewModel.js' 
       } 
    
  3. Save the file in your NetBeans IDE project.