cancel
Showing results for 
Search instead for 
Did you mean: 

How to include multiple facets in annotation ?

02-03-2021 9:41 AM
S0020950018 Discoverer
2095 views 3 comments
0 Likes
SAP Managed Tags
Subscribe

Hi,

I am facing an error while adding a multiple facets in annotation.cds file for a project. For single facets its working for multiple its not. The code which I have used is below plus adding an image of error.

Facets: [ { $Type: 'UI.CollectionFacet', Label: 'Info', Facets: [ {$Type: 'UI.ReferenceFacet', Target: '@UI.FieldGroup#Main', Label: 'Main Facet'} ] }, { $Type: 'UI.CollectionFacet', Label: 'Info 2', Facets: [ {$Type: 'UI.ReferenceFacet', Target: '@UI.FieldGroup2#Main', Label: 'Main Facet'} ] } ], FieldGroup#Main: { Data: [ { Value: OrderNo }, { Value: OrderDesc } ] }, FieldGroup2#Main: { Data: [ { Value: OrderNo }, { Value: OrderDesc } ] },

0 Likes

Accepted Solutions (0)

Answers (2)

Answers (2)

maryana_naboka
Product and Topic Expert
Product and Topic Expert
0 Likes

I would suggest to define a unique ID for each collection facet.

Facets                 : [
        {
            $Type  : 'UI.CollectionFacet',
            ID     : 'test',
            Label  : 'Info',
            Facets : [{
                $Type  : 'UI.ReferenceFacet',
                Target : '@UI.FieldGroup#Main',
                Label  : 'Main Facet',
            },

            ],

        },
        {
            $Type  : 'UI.CollectionFacet',
            ID     : 'test2',
            Label  : 'Info 2',
            Facets : [{
                $Type  : 'UI.ReferenceFacet',
                Target : '@UI.FieldGroup#Main2',
                Label  : 'Main Facet 2',
            }, ],
        },

    ],

BTW: you can also use just reference facets if you do not need extra grouping

    Facets                 : [
        {
            $Type  : 'UI.ReferenceFacet',
            Target : '@UI.FieldGroup#Main',
            Label  : 'Main Facet',
        },
        {
            $Type  : 'UI.ReferenceFacet',
            Target : '@UI.FieldGroup#Main2',
            Label  : 'Main Facet 2',
        }
    ],

maryana_naboka
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Vivek,

the obvious problem is the definition of the second field group.

If you have more than one FieldGroup, they should be uniquely identified through the Qualifier, not through the changes in annotation name. In your case, instead of defining FieldGroup2 #Main you should define FieldGroup #Main2.

Then of course change the reference to this group in the Facet target: instead of Target : '@UI.FieldGroup2#Main', use Target : '@UI.FieldGroup#Main2'

 Facets                         : [
            {
                $Type  : 'UI.CollectionFacet',
                Label  : 'Info',
                Facets : [{
                    $Type  : 'UI.ReferenceFacet',
                    Target : '@UI.FieldGroup#Main',
                    Label  : 'Main Facet'
                }]
            },
            {
                $Type  : 'UI.CollectionFacet',
                Label  : 'Info 2',
                Facets : [{
                    $Type  : 'UI.ReferenceFacet',
                    Target : '@UI.FieldGroup#Main2',
                    Label  : 'Main Facet 2'
                }]
            }
        ],
        FieldGroup #Main               : {Data : [
            {Value : OrderNo},
            {Value : OrderDesc}
        ]},
        FieldGroup #Main2              : {Data : [
            {Value : OrderNo},
            {Value : OrderDesc}
        ]},

I have also noticed that both of your groups contain the same fields.

Best Regards,

Mariana

S0020950018
Discoverer
0 Likes

Hi Mariana,

After trying all this I am getting a duplicate ID error I have also changed the group contains.

Please let me know what should I do to solve this error.

Best Regards

Vivek