cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Field Value from List Card Item on OVP Fiori App to a Fiori List Application

kchatch1
Explorer
0 Kudos

Hi Experts,

I'm trying to find code online for passing a field value from a List Card Item (NOT the header) when it is clicked to another Fiori App.  I have it navigating to the proper app (evidently based on the header annotation), but I haven't found a good example of a list card item anywhere online.  

I am looking for:  

- the code that goes in the Annotations file (both places if necessary)

- what the manifest looks like in both apps (if necessary)

I have attached the parent app annotations file, the receiving app annotations file (webapp2), and the parent app manifest file.  I'm looking for actual code of what the annotations files will look like.  I'm guessing I need to add an entry in the annotations parent app file for the list item (

"dataPointAnnotationPath": "com.sap.vocabularies.UI.v1.DataPoint#total_hits") but I'm not sure.  The field value to pass is aliased as "title" in the Consumption View that underlies the OData Service.  Please help.  

Thanks,

Kevin

 

Accepted Solutions (1)

Accepted Solutions (1)

kchatch1
Explorer
0 Kudos

I got this to work.  It wasn't an annotations-file centric approach, though.  Rather, it involved coding out both controllers for the source and target apps.  

The source app is an OVP Fiori Elements app.  I should note that my work was done in VS Code.  

In the source app, I used doCustomNavigation, but not in the way it is ordinarily used.  As follows:

 
doCustomNavigation: function (sCardId, oContext, oNavigationEntry) {
            var oCustomNavigationEntry;
           
            oOtherBl = "";

            if(oContext.sPath != null) {

                var oEntity = oContext && oContext.getProperty(oContext.sPath);

                if(oEntity.tile.substring(0, 5) === "Other") {
                    oOtherBl = "X";
                }

            }

            return oNavigationEntry;
        },
 
Note: oOtherBl = variable for BOOLEAN of Other category being chosen.  That is all.  
 
I am interested in passing a string of titles (the top 5) to EXCLUDE if they choose the Other title line item.  (If you would like my SQLScript AMDP code for calculating the Other category based on the top N categories of a given column in a table, please let me know.  It is good code).  
 
An array of the top 5, compiled into a string, is of course read in the onInit function of the OVP app controller.  
To get the array, you of course instantiate the oData model and then do .READ.  
 
getParameters passes the Titles to exclude (5 in my case), as follows:
var aCustomSelectionVariant = [];

            if(oOtherBl === "X") {
                var oTile = {
                    path: "tile",
                    operator: "EQ",
                    value1: sTiles,
                    value2: null,
                    sign: "I",
                };
               
                aCustomSelectionVariant.push(oTile);
            }

            return {
               selectionVariant: aCustomSelectionVariant,
               ignoreEmptyString: true
            };
 
I also had of course this to call getParameters:
onCustomParams: function (sCustomParams) {
            if (sCustomParams === "getParameters") {
                return this.getParameters;
            } else if (sCustomParams === "param2") {
                return this.param2;
            }
        }
 
The receiving app is more tricky.  In that controller, we did this:
onInit: function() {
       
            oComponent = this.getOwnerComponent();
           
            this.oRouter = oComponent.getRouter();
            this.oRouter.attachRouteMatched(this.onRouteMatched, this);
        },
       
        onRouteMatched: function(oEvent) {

            this.setNavigationParameters();

        },
 
And this...
 
 onAfterRendering: function() {
           
            var oNavigationHandler = new sap.fe.navigation.NavigationHandler(this);
            var oParseNavigationPromise = oNavigationHandler.parseNavigation();

            oParseNavigationPromise.done(function(oAppData, oStartupParameters, sNavType) {
           
                if(oStartupParameters.tile != null) {
                    sTarget = oStartupParameters.tile[0];
                } else {
                    sTarget = "Header";
                }
            }.bind(this));

        },
 
sTarget being a global var (Other or Header or the Title you want to filter on).  
 
Handling the non-Other category was straightforward.  But this is what was tricky for handling the Other category:
 
if(oFilter.substring(0, 5) === "Other") {

                var aTiles = [];
                aTiles = oFilter.slice(6).split(",");

                var aRanges = [];

                aTiles.forEach(myFunc);
                 
                  function myFunc(item) {
                    aRanges.push({
                        exclude: true,
                        keyField: "App_Title",
                        operation: "EQ",
                        tokenText: "!(=" + item + ")",
                        value1: item,
                        value2: null
                    });
                  }

                var oDefaultFilter = oSmartFilterTab.getFilterData();

                oDefaultFilter.App_Title = {
                    items: [],
                    ranges: aRanges,
                    value: null
                };

                // Set the initial filter values using setFilterData
                oSmartFilterTab.setFilterData(oDefaultFilter, true);
 
So if you're interested in navigating from an OTHER category and then filtering on it (which is something difficult to do, nobody has written about this) this code should be very helpful to you.  Good luck.  
 

 

Answers (0)