如何将SAP Cloud for Customer的扩展字段放置到Embedded Component中

My series of Cloud Application Studio Blogs

Requirement

Create extension field , put it to a given embedded component and finally make it visible in standard UI.

(1) Create an extension field on Opportunity root node and implement an action to calculate whether the current opportunity is over due:

The check logic for over due is simply based on the comparison between current system date and closed date maintained in opportunity header.

import ABSL;
var current = Context.GetCurrentGlobalDateTime( ).GetDate();
var close = this.SalesForecast.ExpectedProcessingDatePeriod.EndDate;
this.IsOverDue = current.GreaterThan(close);

(2) Create a new embedded component OppEC, create two data field and bind them to standard BO field ID and extension field IsOverDue.

Create a checkbox UI element in the embedded component and bind it to ID field.
Create a button in order to execute OverdueCheck action.

Switch to embedded component’s controller tab, create an unbound data field OpportunityID, and use it as BOOperation Read’s parameter. This unbound data filled will be filled with values passed from inport to be created soon.

Create an inport and declare the parameter bound to OpportunityID.

Assign the created event handler to OnFire attribute of this inport.

Create another event handler overDueCheck and bind the BO action OverdueCheck whose implementation is done by our ABSL code.

(3) Add the embedded component to Opportunity TI overview tab,

and bind the parameter defined in standard outport to the parameter declared in my custom inport in embedded component OppEC:

Now we could test in UI: select an opportunity whose close date is yesterday, and click check button:

After that the is Overdue check box is set as selected, meantime we could observe the corresponding roundtrip from Chrome development tool which indicates the due check is done successfully with due indicator marked as X:

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

posted @ 2020-08-31 21:42  JerryWang_汪子熙  阅读(168)  评论(0编辑  收藏  举报