Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
tkbisoyi9118
Participant
1,514
As the UI rules in C4C is not applicable for SDK custom fields and tabs. We cannot control over the behaviors of custom fields or tabs from C4C UI. But we can control the behaviors like “Enabled”, “Mandatory”, “Visible” & “Read Only” using ruby script in SDK UI designer.

In this blog, I will demonstrate how can we control any custom tab or field’s visibility on the basis of another field’s dropdown value using ruby script in the UI designer of SDK.

Let's consider one example: There is one custom BO called “PM” (Plant maintenance) which is having a dropdown field   as “Maintenance Type” with the values as 01- General, 02 – Preventive & 03- Break Down. Two custom tabs are created as “General & Break Down” and “Preventive”. Both the tabs consist of different information corresponding to their maintenance type where “General & Break Down” tab has same type of information and “Preventive” tab has some more information than as “General & Break Down”.

So, when one user will select a particular maintenance type in Maintenance Type field, corresponding to that field value, the respective tab will be visible and other tab will be hidden.

Case1 – Control tab visibility using ruby script.

As you can see in the TI screen of PM BO, 2 tabs are created and maintained as “General & Breakdown” & “Preventive”.


To hide the Preventive tab for general and breakdown type of maintenance, we must follow the below steps:

  1. Open the TI screen in UI designer. Select the tab (General & Breakdown) for which you want to control the visibility via ruby script.

  2. Then go to Properties and select “Visible” under “Behavior” section. Select as Advanced and choose “Calculation Rule”.

  3. Inside the body of “Calculation Rule” write the ruby script code as below.


The code says:  If the maintenance type (M_Type) is General (01) or Breakdown (03) then the “General & Break Down” tab should be visible and the “Preventive” tab should not be visible.

  1. From the Invalidation trigger window select the data field on which the condition is applied and click on “->”.



Same steps need to be followed for “Preventive” tab. Like Select the tab, select “Visible” under “Behavior” section, and choose advanced with calculation rule. Then write the logic: - if maintenance type is “Preventive” (02) then visibility should be true else false for other type of maintenance.


The Result:

There are three types of maintenance.


If I select Breakdown maintenance, then “General & Breakdown” tab is visible and the “Preventive” tab is hidden.


If I select General maintenance, then “General & Breakdown” tab is visible and the “Preventive” tab is hidden.


But when I have selected Preventive maintenance the “General & Breakdown” tab is hidden, and “Preventive” tab is visible.


 

Case 2: Control field visibility using Ruby script.

We can perform this logic to hide/unhide any field as per list value of “Maintenance Type” in UI designer of SDK.

Let’s consider, “Cycle pending” & “Frequency Applied” fields are related to Preventive type of maintenance. So, the requirement is when we are not selecting Preventive type of maintenance these 2 fields should be hidden.

  1. On the TI screen in UI designer select the field you want to hide/unhide. Then under Behavior select “visible” and choose “Advanced” for Calculation Rule.

  2. In the body write the logic as below to satisfy above condition.

  3. From the Invalidation trigger select the field which is maintained in the condition and move to right box. Then Save and activate the UI.




 

The Result:

When I have selected maintenance type as “Preventive” the corresponding fields can be seen in the overview tab.


But when I have selected either “General” or “Breakdown” in maintenance type then those fields are hidden.


Conclusion: -

This solution is very straight and simple. This can be very useful in most of the projects of C4C for such type of requirements. We can use the Calculation rules and ruby scripts for various conditions and different requirements.
Labels in this area