cancel
Showing results for 
Search instead for 
Did you mean: 

Behavior Change in CDS @Common.DefaultValuesFunction: Help Needed!

Sergen_Batman
Explorer
0 Kudos
209

Hello SAP Community!

I've recently encountered a puzzling issue after upgrading to CDS 8.6.1, and I'm hoping someone here might have insights or advice.

Context:

I have a CAP service that uses @Common.DefaultValuesFunction to provide default values for an action in one of my entities. This was working perfectly in CDS 7.9. The getDefaults function was executed with the Business Partner ID as the parameter, allowing me to retrieve context-specific default values.

Here is a simplified snippet of the relevant code:

 

extend service MyService with {
    @CDS.localized: false
    @(Capabilities.SortRestrictions.NonSortableProperties: [to_localData.invitationStatus.name, ])
    entity SupplierEntity as
        projection on bupa.A_BusinessPartner {
            key BusinessPartner,
            Supplier,
            BusinessPartnerFullName,
            BusinessPartnerIsBlocked as isBlocked,
            to_Supplier               : redirected to SupplierDetails,
            to_BusinessPartnerAddress : redirected to BusinessPartnerAddress,
            to_localData              : Association to one MyService.Suppliers on to_localData.ID = Supplier,
            to_customData             : Association to one SupplierCustom on to_customData.Supplier = Supplier
        }
        actions {
            @Common.DefaultValuesFunction: 'MyService.getDefaults'
            action invite @(requires: [
                'connector-advisor',
                'connector-admin'
            ])(email : getDefaultsRet:email,
               leadBuyer : getDefaultsRet:leadBuyer,
               naceCodes : getDefaultsRet:naceCodes,
               topics : getDefaultsRet:topics,
               segments : getDefaultsRet:segments);
            function getDefaults() returns getDefaultsRet;
        }
}

 

The Issue:After upgrading to CDS 8.6.1, I’ve noticed that the getDefaults function is now being executed with the position of the array (an index) instead of the Business Partner ID. This behavior was not present in CDS 7.9, where the function received the correct Business Partner ID contextually.

What I’ve Tried:

  1. Reviewing the CDS documentation: I’ve scoured the release notes and official CAP documentation to see if there were any changes to @Common.DefaultValuesFunction, but I couldn’t find anything definitive.

  2. Debugging the implementation: Adding logs confirmed that the parameter passed to getDefaults is indeed an index rather than the expected ID.

  3. Experimenting with parameter changes: I’ve tried to explicitly pass the Business Partner ID, but no success so far.

Questions for the Community:

  • Has anyone else experienced this issue with CDS 8.6.1?

  • Was there a change in how @Common.DefaultValuesFunction works in recent versions of CDS?

  • Do I need to explicitly pass the Business Partner ID through the caller logic, or is there a better way to adapt to this behavior?

Thanks and best regards
Sergen

Accepted Solutions (0)

Answers (0)