Hello, Alberto.
If it's still relevant for you. Or other members will probably find this useful.
You're correct and on pressing Start Process button in Campaign Automation (which is placed in view set CRM_UIU_CA2/CAViewSet method IF_BSP_WD_TOOLBAR_CALLBACK~GET_BUTTONS) there is a java script code call on client click as startCampaign() for this button. In turn if you check .htm page of the same view you'll find
window.startCampaign = function () { submitRequest("start"); }
The request handling is done in Custom Controller CRM_UIU_CA2/CuCoCA of the same component. Check method PROCESS_REQUEST in its implementation class. You'll find very similar to the following:
CASE lv_action. ... WHEN 'start'. * confirm campaign start lr_tx_manager = cl_mktprj_transaction_mgr=>get_instance( ). IF lr_tx_manager->is_data_loss_handling_needed( ) EQ abap_true. append_jscode( 'popupWindow("startCampaign.do?mode=saveAndConfirm",500,220);' ). ELSE. append_jscode( 'popupWindow("startCampaign.do?mode=confirm",500,220);' ). ENDIF. ...
Yes, this is the next call of js code But it's very straightforward. This code calls CRM_UIU_CA2/startCampaign view of the same component passing different values for its mode parameter.
If you go to the startCampaign view you'll find the method DO_REQUEST of its implementation class. There is already some check in it. The system evaluates surveys from decision and optimization elements.
I'd pay attention how system gets an access to campaign elements here and examine class cl_crm_mktca_processmodel.
Then analyze the htm page of the same view.
Depending on mentioned surveys and mode value system builds a popup view there.
The yesButton actually calls startCampaign() function from this view. In this view it's defined as
function startCampaign() { opener.submitRequest("doStart"); close(); }
So you should look back to the Custom Controller and find the branch in Case statement for 'doStart' value. Here the system starts actual campaign automation (starts workflow WS14000060 with the help of cl_crm_mktca_execution=>start_campaign etc.)
This is how it works.
Where to put a custom check and raise a popup? I'd suggest to enhance Custom Controller's PROCESS_REQUEST method and adjust it according to your needs. Probably you should call a popup similar to startCampaign popup but according to your checks.
Hope this will help you.