When we open any service contract, we can see these one click actions in the item assignment block. These actions help us to edit some important fields of line item there itself in the table view. We need to not navigate to item overview page to edit it and also we can delete that item on the same assignment block.
Let us provide one click action for a table view. Here I am going to add OCAs to the table view that I created in the chapter VALUE NODE CONCEPT. However procedure that we follow applies to any table view.
Step1.
We need to add one value attribute with name THTMLB_OCA with type CRM_THTMLB_ONE_CLICK_ACTION to the context node of table view.
Go to the table view context node for which you want to implement ONE CLICK ACTIONS. Add a value attribute as mentioned above. Kindly see the below screen shots for reference.
Complete the wizard. We have created the attribute.
Step2.
Move the newly created attribute to the displayed fields section on the view configuration tab.
Step3.
Go to the context node class of table and redefine the method GET_OCA_T_TABLE.
Write the following code inside that method and activate the method. In this method we have added buttons.
METHOD get_oca_t_table.
DATA:ls_one_click_action TYPE crmt_thtmlb_one_click_action.
ls_one_click_action-id = 'EDIT'.
ls_one_click_action-icon = 'edit.gif'.
ls_one_click_action-text = ''.
ls_one_click_action-tooltip = 'Edit Record'.
ls_one_click_action-active = 'X'.
APPEND ls_one_click_action TO rt_actions.
ls_one_click_action-id = 'DELETE'.
ls_one_click_action-icon = 'delete.gif'.
ls_one_click_action-text = ''.
ls_one_click_action-tooltip = 'Delete Record'.
ls_one_click_action-active = 'X'.
APPEND ls_one_click_action TO rt_actions.
ENDMETHOD.
复制代码
Step4.
We need to tell the framework about newly created value attribute is an OCA type. For that we need to code in the P getter method of new attribute.
If P-getter is greyed out, then just double click on. Framework will ask to create it. Then choose yes. Then write the following code inside the method.
Here ‘_oca’ is the event handler name that will be triggered when we click on edit or cancel buttons.
Step5.
Create on event handler with name _oca. (event handler name is case sensitive ).
Here for two buttons only one event handler is assigned. So whether you click on EDIT button or DELETE button, same event handler will be triggered. So we need to know on which button user has clicked to process our logic.
Write the following code inside the event handler and activate it.
METHOD eh_on_oca.
DATA:lv_event TYPE string,
lv_index TYPE c LENGTH 2.
SPLIT htmlb_event_ex->event_defined AT '.' INTO lv_event lv_index.
CASE lv_event.
WHEN 'EDIT'.
WHEN 'DELETE'.
WHEN OTHERS.
ENDCASE.
ENDMETHOD.
复制代码
We are getting the ID of buttons on which user has clicked. Based on the button id, We need to process our own logic.
Test the application by placing a break point in the above event handler.
Let us provide one click action for a table view. Here I am going to add OCAs to the table view that I created in the chapter VALUE NODE CONCEPT. However procedure that we follow applies to any table view.
Step1.
We need to add one value attribute with name THTMLB_OCA with type CRM_THTMLB_ONE_CLICK_ACTION to the context node of table view.
Go to the table view context node for which you want to implement ONE CLICK ACTIONS. Add a value attribute as mentioned above. Kindly see the below screen shots for reference.
Complete the wizard. We have created the attribute.
Step2.
Move the newly created attribute to the displayed fields section on the view configuration tab.
Step3.
Go to the context node class of table and redefine the method GET_OCA_T_TABLE.
Write the following code inside that method and activate the method. In this method we have added buttons.
Step4.
We need to tell the framework about newly created value attribute is an OCA type. For that we need to code in the P getter method of new attribute.
If P-getter is greyed out, then just double click on. Framework will ask to create it. Then choose yes. Then write the following code inside the method.
Here ‘_oca’ is the event handler name that will be triggered when we click on edit or cancel buttons.
Step5.
Create on event handler with name _oca. (event handler name is case sensitive ).
Here for two buttons only one event handler is assigned. So whether you click on EDIT button or DELETE button, same event handler will be triggered. So we need to know on which button user has clicked to process our logic.
Write the following code inside the event handler and activate it.
We are getting the ID of buttons on which user has clicked. Based on the button id, We need to process our own logic.
Test the application by placing a break point in the above event handler.
Click on any button. I clicked on DELETE button