cancel
Showing results for 
Search instead for 
Did you mean: 

Hide DataField in Fiori Elements using @UI.Hidden

Mattias
Active Participant
0 Kudos

Hello,

We're trying to hide a DataField in Fiori Elements using @UI.Hidden in our local annotation file, but it still shows up in our app. We've tried refreshing the browser and also logged in using Incognito-mode, but to no avail.

We've added the following to the annotation.xml

<Record Type="UI.DataField">
    <PropertyValue Property="Value" Path="attendees_number"/>
    <Annotation Term="UI.Hidden" Bool="true"/>
</Record>

Regards

Mattias

former_member590722
Discoverer
0 Kudos

Hi Mattias,

Are you trying to hide the DataField of an annotations project in a SmartTable or SmartField?

Kind Regards,

Jahanvi

External

On behalf of SAP Product Support

Accepted Solutions (1)

Accepted Solutions (1)

Mattias
Active Participant
0 Kudos

We found the answer, we're on UI5 1.52, when running it on version 1.64 in the FLP sandbox it works, seems @UI.hidden is broken in 1.52.

Answers (3)

Answers (3)

former_member182874
Active Contributor

Hi Mattias,

If that is the case, you can try doing from UI5 custom code as well in controller extension.

First get the entire model from your CDS and in object page, where you are showing the field group. Based on some flag, you can hide the field for certain data. In this case model will be same as coming from CDS or OData, but in UI layer you can hide it based on your condition. Hope I am understanding your requirement correctly.

Regards,
Tejas

Mattias
Active Participant
0 Kudos

Hi,

That would maybe work, but we're in the process of upgrading to the latest UI5 component anyway, we will leave this as-is for now, since we've tested it on the newer version and it works.

Thank you for your help.

Regards

Mattias

former_member182874
Active Contributor
0 Kudos

For such logic you should handle in odata. Use SEGW project, create a CDS reference and modify the metadata based on the condition in your MPC or DPC class.

Moreover do you want to say that for certain condition the whole report will not show the data field ? In List report, either you can hide the column for entire data (as datafield is nothing but a column in responsive table). If you want to modify the field in row level, i think you can still play with the data but not the column.

Mattias
Active Participant
0 Kudos

It's not a data field in a LineItem, it's a data field in a FieldGroup, basically we don't want to show the field "Number of Attendees" for certain types of activity. Currently we have a calculated field in the CDS that returns 'X' or '' depending on whether we should show the field or not

  cast( case activity_data.process_type
       when 'Z004' // Kundanpassat seminarium
         then ''
       else
         'X'
       end
       as BOOLE_D) as hide_attendees_number,

We bind this field to @UI.hidden in the annotation.xml-file, but it is not working. Since it doesn't work if we set the field to false hard, as per my first example, but it works when we set it in the CDS, it seems the app is ignores our local annotation file.

If I'm not mistaken the MPC is only called once when opening the app, not when we load a new entity, so I don't think it would work to put the code in the MPC? Please correct me if I'm wrong.

maheshpalavalli
Active Contributor
0 Kudos

Mattias Johansson Your scenario works with draft enabled solution, does your system support draft concept?

BR,

Mahesh

Mattias
Active Participant
0 Kudos

Hi, no, it does not, we're on Netweaver 7.50, so no drafts for us yet. But why would this be required to hide a field dynamically?

Anyway the problem isn't the calculated property, but even if we put the following in our Annotations file it is not hidden, only if we do it in the CDS

<Record Type="UI.DataField">
    <PropertyValue Property="Value" Path="attendees_number"/>
    <Annotation Term="UI.Hidden" Bool="true"/>
</Record>
former_member182874
Active Contributor
0 Kudos

Did you try removing the clone option, reclone Local annotation and try. Sometimes the changes are not reflected. Or for effective hiding, write the same in CDS, below @UI.lineitem

Regards,

Tejas

johan_wigert
Active Participant
0 Kudos

It works fine when adding

@UI.hidden: true

in the CDS. However we would like to hide the field dynamically based on some custom logic. We're not aware of any way of doing this in the CDS. We therefore created a new virtual attribute in the CDS, which we want to use in the annotations XML file to control the visibility of the field.