In this blog, we will talk about Home Page Card. It supposed to be about Home Page Tile, however, in 1902 SAP introduced Home Page Cards. Tiles are staying till 1905 according to the recent release preview information.
From the perspective of the current blog, cards are the same as tiles. They are just rendered differently.
In 1811 release SAP introduced very nice thing as HTML or URL mashup tiles. Quite a powerful extension to the options we have to customise Home Page. However, the topic I’d like to talk about is still not covered by SAP standard delivery.
This blog describes the solution to the question I raised myself quite some time back ago and which was not answered until recently: Custom Tile on the Home page. Can we make a selection through parameters?
There are quite a few standard cards available to bring them on the home page. They are all under Filters group when we would go and use “Add Existing Cards”.
However, how about our very own custom filter?
Since it’s not yet possible out of the box, I decided to go with DIY (do it yourself) approach. Long story short, I succeeded. Moreover, here I’d like to share with the Community step-by-step guide and walk through it.
How to create a custom card (aka custom tile) which would navigate a user to some OWL and apply any predefined selection (DefaultSet) immediately?
Let’s say I created a new query via master layout change in the Visits search page. I wanted it to be “My Visits Today In Progress”. I did it as Administrator user so the query is available to any user. I assume the Reader is familiar with the process so far and we created the query successfully.
We are creating a custom card for home page the standard way we can select Type as Floorplan. We need to give a title and a path.
We will use this Floorplan type of cards. However, we need to properly compose the path and do one more trick.
The path needs to be in the following format:
$root-< WorkCenterPath >-< WorkCenterViewName >-< OWLName >::< Inport >::< DefaultSetName >
Let’s figure out where to get all those parameters from.
Some of these parameters need to be obtained with the help of our fellow developer.
< WorkCenterPath >
The developer needs to look into SDK UI Designer and find the Work Center you’d like to navigate to. In my case, it’s Visits Work Center.
The developer should provide you with the attribute of this Work Center called “Unique Id” or right click Work Center in Configuration Explorer and press “Copy ID”. And this is going to be our which for my case is /BYD_COD/SalesOnDemand/Visit/COD_Visit_WCF.WCF.uiwoc
< WorkCenterViewName >
Being in the same Work Center, the developer needs to navigate to Work Center View we need and for example, clicking on WorkCenterView Path link or via Configuration Explorer. There we need to get “Name” of Work Center View.
< OWLName >
Staying in the same Work Center View, the developer needs to open OWL component embedded into this view and give you its name.
< InportName >
This is a bit tricky. We need to find which import in OWL component will suit our needs. Usually, it would be some inport with the name like FromCODHomePage. I checked and OWLs used in Visits, Accounts, Appointments, E-mails, Phone Calls, Tasks, Leads, Tickets all have such an inport with the same name.
However, if it’s not there in your particular case, the import we’re interested in would have one parameter with the binding to a data model field which in turn is used in “Active DefaultSet Binding”. Alternatively, an event handler should be assigned to the import which would also execute the passed defaultset somehow. In short, a bit of exploration might be required here. In the end, we should find the existing import to pass default set to.
Here the example from Visits OWL.
We’re almost done with the Path. The last parameter left is
< DefaultSetName >
If we were after any standard DefaultSet (or DefaultSet created in UI Designer because the approach works for custom OWLs as well), we would grab DefaultSet name straight from UI Designer.
However, we’re after the DefaultSet (aka Query) created via master layout. Since anything created in master layout change mode is not reflected in SDK UI Designer, we’re leaving UI Designer aside.
Here we need to launch C4C UI in debug mode. How to do it? Please have a look at my other blog post: SAPUI5 and C4C. My (un)expected journey. Preparation.
Having UI running in debug mode (remember – we need some patience here because it may take some time to load), we need to navigate to our Visits Work Center then View. Being there we need to press Ctrl+click on the dropdown where we select any of predefined query to open Client Inspector. In the end, we need to get Client Inspector showing us AdvancedListPane (Control) in Control Tree as the first element.
Scroll down the control tree in Client Inspector till we see DefaultSets. DefaultSets with Stable Anchor are usually those who are coming from UI Designer. We’re looking for those DefaultSets which are without Stable Anchors. One of such DefaultSets is most likely to be the one we’re looking for. Once we select the DefaultSet in the control tree, on the right-hand side, we’ll see its attributes. We’re looking for its “defaultSetName”.
DefaultSets created in master layout have names which start with “$PersonalizedDefaultSet-“.
But how to identify exactly which is ours since there might be many custom queries created?
For this, switch to “Component Model XML” tab in Client Inspector and search for your query description. Then locate the name attribute in the DefaultSet tag where we found our description. In my case the default set name is $PersonalizedDefaultSet-MyTodayVisits-9b1b
Ok, we have all parameters and my path for custom card looks like:
If you went and created a custom card right here with type Floorplan, providing Title and the Path similar to the above one, you would get an exception when trying to press such card. That’s because we haven’t finished yet.
Now here comes the trickiest part.
Out of the box, Floorplan card works only with a path to open a certain Work Center View. For example, the path below doesn’t produce an exception but opens Visits search page with default query.
/BYD_COD/SalesOnDemand/Visit/VisitExecution/COD_Visit_WCVIEW.WCVIEW.uiwocview (this is the Unique ID of the Visits Work Center View)
However, we want to open our exact query.
For this, we need to start to create a custom card, select the type as Floorplan, provide Title and the path with the DefaultSet we want to open. But don’t press Save yet!!
Then we need to open developer tools. I prefer to use Chrome Developer tools but it’s your choice. Remember, it’s important to be in UI debug mode (or in SAPUI5 debug mode with sap-ui-debug=true parameter in URL when launching UI). This has made the source code be loaded in an uncompressed format.
We search for _createNewTileCatalogObject in all files ( Ctrl+Shift+F will open the search view if it’s hidden). The result hopefully is like the below. Click the highlighted entry in PersonalizationPage-dbg.js and it will open us the source code. This is the function where a new tile object is created once we click Save.
We put a breakpoint right after the oCat object created (on oCat.ANY_DATA ….).
Now we hit Save button on “Create Custom Card” screen. The debugger is stopped at our breakpoint.
All we need to do here is to change oCat.NAV_OBJ_TYPE from FLOORPLAN to OWL_INPORT.
Notice that I did it in Scope-Local on the right-hand side rather than in Console. It’s not the part of this blog, but the change made in Console doesn’t work.
And then continue script execution with F8.
We’re all done! Publish the change to the Home Page and we’re good to go and test.
Now we have our DIY custom card which once pressed navigates us to the Visits Work Center View with configured predefined query created via master layout. And it’s available to any user. You as Administrator just need to assign the card to any business role and publish the home page changes.
Luckily, I don’t have any visits in progress for today. Yay!
If you want to show the number of found entries on such DIY card as it’s shown, for example, on “My Open Tasks” or “My Visits Today” cards, I have bad news for you. Currently, it’s not possible. SAP executes some backend services to get totals only for very limited predefined queries. Such as “My open tasks”. And unfortunately, there is no way to enhance this place as of now.