Tuesday, 4 June 2013

58.ONE CLICK ACTIONS



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.





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











5 comments:

  1. Thank you for the gr8 post..
    I have a question.. If we want to display any other image instead of 'edit' or 'delete'. How are we going to it??

    ReplyDelete
  2. Thank you very much for very helpfull entry!

    ReplyDelete
  3. if i want to edit a particular column in row level wat i want to do...

    ReplyDelete
  4. Hey, what if my requirement is to remove the standard one click action column of a table view? any suggestions or will you write a new topic for these?

    ReplyDelete
  5. Thank you for this helpfull article.

    ReplyDelete