Pages

Wednesday, June 15, 2016

How to create data loss popup in CRM WebUI



When navigating from one custom component to other components or documents using Quick links or Navigation bar links we need to restrain user from accidentally deleting the  unsaved data, to achieve this we prompt data loss popup, which requires user input to proceed further. 

Below are the steps to create a data loss popup: 



STEP 1: Create a method with the name ON_BEFORE_WA_CONTENT_CHANGE in window                    implementation class with following properties:

                                      Level : Instance Method
                                     Visibility: Protected

STEP 2: Click on the method and click on Detail View button which is near parameters and set the                   following settings by clicking on Event handler for checkbox:

                                     Class/Interface: CL_BSP_WD_VIEW_MANAGER
                                      Event: BEFORE_WORKAREA_CONTENT_CHANGE
           and save the settings.
STEP 3:  Set the following settings for parameters:
                                     Parameter: DATA_LOSS_HANDLER
                                     Type: Importing
                                     Typing Method: Type Ref To
                                     Associated Type: IF_BSP_WD_DATA_LOSS_HANDLER


STEP 4: Write the following code into the above method:
  data_loss_handler->set_save_handlerme ).
  data_loss_handler
->set_revert_handlerme ).
  data_loss_handler
->set_cancel_handlerme ).
  data_loss_handler->trigger_data_loss_handling( ).

 

STEP 5: Redefine the method DO_VIEW_INIT_ON_ACTIVATION and write the following line: 
        
            SET HANDLER on_before_wa_content_change ACTIVATION abap_true.

STEP 6: Add interface IF_BSP_WD_EVENT_HANDLER in main your window. Implement the method IF_BSP_WD_EVENT_HANDLER~HANDLE_EVENT

CASE iv_event_name.
    WHEN if_bsp_wd_data_loss_handler=>save_event.
    rv_success = abap_true.
    WHEN if_bsp_wd_data_loss_handler=>revert_event.
     rv_success = abap_true.
    WHEN if_bsp_wd_data_loss_handler=>cancel_event.
     ...
 ENDCASE.
 

 
 






And write the logic in these cases and when yes or no button is pressed leaves current component.

No comments:

Post a Comment