且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

更新时间:2022-09-05 23:17:20

My series of Cloud Application Studio Blogs

How to detect EditMode in an Embedded Component

Step by step to enable your custom BO with attachment upload functionality

Step by step to create an Adobe Print form in Cloud application Studio

How to render PDF which displays picture from the image attachment of your custom BO

How to get current logged on business user’s employee information and assigned organization unit via ABSL

How to implement dynamic access control based on custom BO using OWL

How to make Code List Restriction work when control field and restricted field are not on the same BO

How to implement custom number range using custom business object

Two approaches to create Code List in Cloud Studio

Create Dynamic Code List via Custom Business Object Association

Step by step to develop Thing Type based navigation and BO Object based navigation

Put Extension field into embedded component and make it visible in Standard UI

One possible cause that embedded component fails to display in UI

Step by step to create HTML Mashup and make it visible in UI

Step by step to enable Text Collection for your custom BO

Automatically send an Email notification to line manager via Workflow in Account application

Step by step to create Object Value Selector in Cloud Application Studio

Two approaches to fill an UI field with dedicated logic implemented in Cloud Application Studio

How to execute BO action on multiple selected BO instances in AdvancedListPane

How to add custom validation logic on mobile phone field in Contact TI

Suppose the requirement is to display “Assigned Organization Unit ID” of current log on user in your custom UI, for example if I log on system with business user for Jerry, it is expected that my current organization unit ID TESTORG will be displayed in my custom UI.

两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

There are two approaches to achieve this in Cloud Application Studio.


Approach1: Implement AfterLoading event

Create a transient field in custom BO:


两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

Implement the AfterLoading event:

两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

Source code of AfterLoading Implementation:

两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

In the implementation, two functions defined in Reuse library JerryTestReuse are used:

两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

Source code for function getAssignedOrgID:

两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

Source code for function getCurrentEmployeeUUID:

两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

Approach2: Specify a transformation to a dedicated field

First create another function in Reuse Library:

两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

Source code:

两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

Create a new data field in UI Model,

两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

And create a new transformation and assigned to this field:

两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

When assigning the transformation to the Data field, you should see this popup dialog,

两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

Choose Yes to convert the Data field into a Dedicated Field. Once done, the assigned transformation will be displayed in Properties window.


两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

When you test both solution in UI, you could observe that the execution of AfterLoading and Transformation and done in the backend and calculation result is contained in HTTP response.


This is different from the behavior introduced in blog How to change UI element visibility dynamically via Rule Editor – and how it works under the hood – in that case the visibility calculation is performed in frontend instead.

两种在SAP Cloud Application Studio里通过编程对C4C UI字段赋值的方法

Further reading

In CRM there is also similar function supported – so called Calculated Fields created and edited in SAP CRM Application Enhancement Tool ( AET ). Please see more technical detail about Calculated Fields in CRM from this blog

Insight into calculated fields created by AET.