Skip to Content

Update texts on Fiori Elements Object Page after changing field value

Hi,

I have created a Fiori Elements List Report app around an annotated CDS view. This view contains associations to other (SAP standard) CDS views to give texts/descriptions for the 'codes' entered and value help for those fields.

When I go into Edit mode on the object page, change the 'code' value in a field and Save, the text against that field does not change, but remains the text for the previous code. Only when I navigate back to the List page does the OData service get queried again and the texts updated.

I realise that standard OData for an Update request is just to send back a 204 (No Content) to confirm that the update has been accepted. I can't help thinking that the app should automatically be issuing a Read for the changed object so that the association (text) data is up-to-date.

Is there a way of 'asking' the app to re-Read the entity from the Object page after an edit has taken place (preferably via annotations or BOPF changes rather than an extension in the app)?

Thanks,

Andrew

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Oct 04 at 02:19 PM

    Hello Andrew

    You can achieve this by annotating side effects. You can do this with local annotations in the WebIDE or in the MPC of the service. By coding this could look something like this:

        DATA:
          lo_ann_target TYPE REF TO /iwbep/if_mgw_vocan_ann_target,
          lo_annotation TYPE REF TO /iwbep/if_mgw_vocan_annotation,
          lo_record     TYPE REF TO /iwbep/if_mgw_vocan_record,
          lo_collection TYPE REF TO /iwbep/if_mgw_vocan_collection,
          lo_property   TYPE REF TO /iwbep/if_mgw_vocan_property.
    
        lo_ann_target = vocab_anno_model->create_annotations_target( iv_target = '<target>' ).
        lo_annotation = lo_ann_target->create_annotation( iv_term = 'com.sap.vocabularies.Common.v1.SideEffects' iv_qualifier = '<qualifier>' ) ##NO_TEXT .
        lo_record = lo_annotation->create_record( ).
    
        "Side effect type
        lo_record     = lo_annotation->create_record( )  ##NO_TEXT.
        lo_property   = lo_record->create_property( 'EffectTypes' )   ##NO_TEXT.
        lo_property->create_simple_value( )->set_enum_member_by_name( 'ValueChange' ).
    
        "Source properties
        lo_property   = lo_record->create_property( 'SourceProperties' )   ##NO_TEXT.
        lo_collection = lo_property->create_collection( ).
        lo_collection->create_simple_value( )->set_property_path( '<property>' ). "Name of the property that is changed e.g. your code value
    
        "Maybe some more properties using the same value help...
        "lo_collection->create_simple_value( )->set_property_path( '<property>' ). "Name of the property that is changed e.g. your code value
     
        "Target entities
        lo_property   = lo_record->create_property( 'TargetEntities' )   ##NO_TEXT.
        lo_collection = lo_property->create_collection( ).
        lo_collection->create_simple_value( )->set_nav_property_path( '<property>' ). "Name of the navigation property of the association e.g. to_Code

    Unfortunately the side effect is only triggered if the focus of the control is blurred (onBlur). As long as the cursor stays in the control (inputfield or dropdown) the side effect is not triggered. This is especially annoying if a value help is attached to the inputfield or the control is a dropdown. After selecting a value the user has to "step out" of the control (by pressing tab or clicking with the mouse into another control) in order to make the side effect happen. In case of selecting a value from the dropdown or the valuehelp i think this behaviour is actually not correct as the user has changed the value by this prior action. If it is only a inputfield then it is ok to wait until the user "leaves" the field to trigger the side effect. Maybe this will be fixed some day by SAP...

    Regards
    Gabriel

    Add comment
    10|10000 characters needed characters exceeded