Restrict AutoSave on End Button in IC-Agent Role
Summary
Agent or User whenever click the End Button in Web IC, Interaction center is designed in such a way that all unsaved data from current customer interaction data with its all business object/links gets Saved.
The purpose of the document is to stop or restrict auto-save in IC-Agent role.
Introduction :-
In this document IC role, I would like to take example of Service request – If an Agent is trying to create a new service request and if he push End button on a toolbar, System should not save the service request data and navigate to Account Identification page.
Step 1. Open to the Service request component SRQM_INCIDENT_H, from bsp_wd_cmpwb tcode.
Step 2. Open the Header View SRQM_INCIDENT_H/IncidentHeaderEF
Step 3. In the View IMPL class add a new IC event service interface IF_CRM_IC_EVENT_LISTENER
This controller implementation class will show you that it has a method HANDLE_EVENT that
accepts the event name as parameter, that further will have to be implemented.
Step 4. Before implementing Handle_event we first must subscribe this handler to the event to which it will be listening.
This can be done in DO_VIEW_INIT_ON_ACTIVATION method, this method is generally used for registering handlers.
CALL METHOD SUPER->DO_VIEW_INIT_ON_ACTIVATION.
DATA : lr_event_srv TYPE REF TO if_crm_ic_event_srv.
lr_event_srv = cl_crm_ic_services=>get_event_srv_instance( ).
lr_event_srv->subscribe( event_name = cl_crm_ic_interaction_manager=>event_interaction_end_request
listener = me
prio = '1').
Step 5. Next to code in Handle_event method of IC controller implementation class in which event is registered as handler.
When Agent clicks on End button Event_interaction_end_request is called, and here is a code to revert the transaction before saving.
DATA : lr_entity TYPE REF TO cl_crm_bol_entity.
DATA : lr_tx TYPE REF TO if_bol_transaction_context.
DATA: lv_guid TYPE crmt_object_guid.
DATA : lr_core TYPE REF TO cl_crm_bol_core.
DATA : lr_comp TYPE REF TO zl_srqm_bspwdcompone0_impl.
CASE event->get_name( ).
WHEN cl_crm_ic_interaction_manager=>event_interaction_end_request.
lr_comp ?= me->comp_controller.
IF lr_comp IS BOUND.
lr_entity ?= lr_comp->typed_context->btadminh->collection_wrapper->get_current( ).
CHECK lr_entity IS BOUND.
CALL METHOD lr_entity->if_bol_bo_property_access~get_property_as_value
EXPORTING
iv_attr_name = 'GUID'
IMPORTING
ev_result = lv_guid.
lr_core = cl_crm_bol_core=>get_instance( ).
lr_entity = lr_core->get_root_entity( iv_object_name = 'BTOrder' iv_object_guid = lv_guid ).
IF lr_entity->alive( ) EQ abap_true.
lr_tx = lr_entity->get_transaction( ).
IF lr_tx IS BOUND.
lr_tx->revert( iv_suppress_buffer_sync = abap_true ).
ENDIF.
ENDIF.
ENDIF.
ENDCASE.
If you want to check the functionality of End button, you can open a component CRMCMP_IC_FRAME
View -> CRMCMP_IC_FRAME/HiddenView, Method EH_ONFORWARDCALL is implemented in class
you can debug the standard code this below raise method will call handle event which we have implemented and revert the transaction.
ref_event_service->raise( ref_event )
Please also refer for more information check How To Stop Auto Save while clicking End Transaction Button in Ic_agent Buss Role
Not the best way in my opinion actually. Sumeet, if you're referencing the discussion you should know that there is also another way which I described there (and it's marked as a correct answer there btw). I'm talking about using IF_CRM_IC_PREPARE_FOR_CALLBACK. It seems to be better because you just need to raise a veto flag and all other things the system will do for you.
Thanks for the reply Andrie, I have first applied as per your suggestion on discussion.... I implemented IF_CRM_IC_PREPARE_FOR_CALLBACK interface and on execute method i put a break-point and checked,
the implementation is not getting called on click End button i my case service request, so cant raise veto.
Is there something to subscribe or register call back event, please reply ????
i have use this code .....
DATA: lv_mandatory TYPE bsp_dlct_fieldname,
lv_veto TYPE abap_bool.
* check, if mandatory fields are filled
lv_mandatory = get_empty_mandatory_fields( ).
IF lv_mandatory IS INITIAL.
veto = abap_true.
* No veto, view can be left without further action from the agent
ELSE.
* Veto, agent needs either cancel or save the creation or at least enter mandatory fields
endif.
Regards,
Sumeet
Have you registered your class (which implements mentioned interface) for callbacks? Something like below (in DO_INIT_CONTEXT from example):
DATA: lr_cb_registry TYPE REF TO if_crm_ic_callback_registry.
lr_cb_registry = cl_crm_ic_interaction_manager=>get_cb_registry_end_request( ).
lr_cb_registry->register( me ).
Thanks Andrie , I have not register the class i will try this....
Hi Andrei,
I have registered the class and raised a veto in the call back execute method, Now its restricting to save the service request that is perfectly fine, but not navigating to home page as per as standard behavior and call or remains on the same page of the service request.
I m not sure m i missing something ??
Regards,
Sumeet
You should raise the veto if anything is wrong. If everything is fine then you have to leave veto empty. Something is in your code or logic.
Hi Sumeet,
It is nice blog.
Thanks for posting this.
Regards,
Hrishikesh.