如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action

i042416發表於2020-09-27

My series of Cloud Application Studio Blogs

Recently one partner asked me about this question. Suppose I have a custom BO with one Date field “CloseDate”, and one indicator field “IsOverDue”.


如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action


There is an action “OverDueCheckMass” defined with the simple logic that if current date < Close Date, then I consider the order as Overdue and vice versa. The source code of this action implementation:

import ABSL;var current = Context.GetCurrentGlobalDateTime( );foreach( var rootNode in this ){
    var closeDate = rootNode.CloseDate.ConvertToGlobalDateTime();
    rootNode.IsOverDue = current.LessThan(closeDate);}

This action is marked as Mass-enabled.


如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action


Requirement is: in the table implemented by AdvancedListPane in UI Designer, if several rows are selected by Ctrl+Click ( Or Shift + Click ), once the button “Overdue check” is pressed, the action must be performed on those selected rows.

Take the below screenshot as example, the first and fourth row are selected, it is expected that after OverDue check is executed, IsOverDue indicator for the first row is determined as Yes.


如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action


Here below is details step how this requirement could be fulfilled.

(1) Specify the List SelectOption property as “multiSelectWithLeadSelection”.


如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action


Create a Data List in DataModel tab:


如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action


(2) Create an event handler with type BOAction. For instance Binding attribute, bind it to the Data List created in previous step. Choose “multiple” as Action Type and bind this event handler to BO Action OverDueCheckMass.


如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action


By default when you create a new event handler, Action Type is always set as single by default. Don’t worry, once you bind this action to the Instance Binding which points to a Data List in your Data Model and the BO action implementation is Mass-Enabled, once you click bind button, this Action Type will change into multiple automatically.


如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action


After these two steps are done, select the first and fourth row and press the OverDue check button – it works as expected.


如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action


How it works under the hood

Suppose you have first pressed Ctrl key and then select the first and fourth row, how UI5 framework reacts to this event? Set a breakpoint on function OnClick of file TablePointerExtension.js, and there is one attribute ctrlKey in the native HTML event object which indicates whether the Ctrl key is pressed in current event.


如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action


With this indicator, UI5 framework could react accordingly:


如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action


Since I have selected the SelectOption of my list as multiSelect, so UI5 uses an array to store the selected rows’ indexes:


如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action


Now when you click Overdue Check button with the state that first and fourth rows are selected, the breakpoint set in method SendAsyncPostRequest in file Request.js will be triggered. Check what exactly the data will be sent to backend by inspecting variable mParameters:


如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action


It clearly shows that the node ID of selected two BO instances are passed to backend for action execution.

要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":

如何在SAP C4C AdvancedListPane上批量執行若干BO例項的action


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2724401/,如需轉載,請註明出處,否則將追究法律責任。

相關文章