Tuesday, April 11, 2017

Fluid UI - Tile Wizard API for Dynamic Tile Content

PeopleTools 8.55 introduced the Tile Wizard App Classes which enable us to use the API to dynamically modify Tile Content.

PeopleBooks: Tile Wizard Classes

There are three main areas in the Tile where we can add dynamic content - Tile Content, Live Data and Badge.

Here is an example of how we can use the Tile Wizard Classes to dynamically update the content of a Tile as shown in the example below.


Step 1: Implement a custom App Class that extends PTGP_APPCLASS_TILE:Tiles:Tile



Notes:
- Make sure the App Package contains a Sub Package. Otherwise, we might run into errors as stated in this HEUG Technical Forum discussion.
- We can use the %This.SetTileContentAs... methods - %This.SetTileContentAsTwoKPIs() in this case - to override the "Tile Content Type" configured using the Tile Wizard (which we will perform in step 2).
- We can also use the various Tile Class Properties to set the Tile Content (e.g.: KPI values and labels), Live Data (values, trend image and metrics formatting) and Badge Data.

Step 2: Create Tile using Tile Wizard

NavBar > PeopleTools > Portal > Tile Wizard > Create Tile



Notes:
- We can see that the App Class created in step 1 is referenced as the Data Source.
- Also, the "Tile Content Type" is set to Image in the Wizard configuration level (although it will be overwritten using PeopleCode).
- Similarly, the "Tile Badge" is set to "No" in the Wizard configuration but it can be overwritten using PeopleCode.


Note:
- For the purposes of this example, I set the Target Page to "PS Unit". This can be set to anything as per our requirement.


Note:
- The Tile image is set to PTFP_DEFAULT_CLOUD as a dummy. It will not be used in this case, because we will be overriding the "Tile Content Type" via PeopleCode.


Step 3: Add Tile to a Fluid Homepage

Fluid Home > Action Menu > Personalize Homepage


Results:


Environment Details:

- CS 9.2
- PUM Image 4
- PeopleTools 8.55.12

Related Posts:
Part 2
Part 3

PeopleCode for Reference:

import PTGP_APPCLASS_TILE:Tiles:Tile;

class TILE_1 extends PTGP_APPCLASS_TILE:Tiles:Tile
   method TILE_1();
   method getTileLiveData();
end-class;

method TILE_1
   %Super = create PTGP_APPCLASS_TILE:Tiles:Tile();
end-method;

method getTileLiveData
   /+ Extends/implements PTGP_APPCLASS_TILE:Tiles:Tile.getTileLiveData +/
  
   %This.SetTileContentAsTwoKPIs();
   /* 1 KPI tile content */
   %This.TileKPI_1 = %This.getAmountFormattedValue(1.23456789, "USD");
   %This.TileKPI_1_Label = "KPI1_1 Label";
   %This.TileKPI_2 = "KPI_2";
   %This.TileKPI_2_Label = "KPI_2 Label";
  
   /* Live Data */
   %This.TileLiveData_1 = "LD_1";
   %This.TileLiveData_2 = "LD_2";
   %This.TileLiveData_3 = "LD_3";
  
   /* A trend arrow is an optional element of live data. */
   %This.hasLivedataTrendImage = True;
   %This.TrendImage = %This.k_strTrendDownImage;
  
   /* Metrics Formatting */
   %This.isTileLiveData_1_Metrics = True;
   rem %This.isTileLiveData_2_Metrics = True;
   rem %This.isTileLiveData_3_Metrics = True;
  
   /* Badge */
   %This.hasLiveDataCount = True;
   %This.TileTransCount = 7;
  
end-method;

32 comments:

  1. Hi there! First off, great tutorial! Already thinking of all the things I can do with this.

    I'm curious, is there anyway to control properties of the tile itself like height and width? Or is that only possible through the CRef you select?

    ReplyDelete
    Replies
    1. another question, is it possible to disable the link to the CRef? Disabling the main hotspot seems to override the custom app package.

      Delete
    2. Hi Eric - Good questions! The first one would be a great enhancement idea. I don't think there is any way we can dynamically adjust the Tile dimensions. Interesting thing I found is that once we use the tile wizard, the Tile CREF that is generated no longer has the 'Fluid Attributes' tab, since it is created as a CREF link. We will need to adjust the properties on the underlying CREF.
      Refer CREF Link: https://snag.gy/0TcgGs.jpg
      Refer CREF: https://snag.gy/W3hvUc.jpg

      You second question is actually worth a separate blog post! :)

      I found the solution to your problem, instead of setting the 'Disable Main Hotspot' on the Tile Wizard, go to the actual CREF that you would end up on (in my example https://snag.gy/K9LP5E.jpg) when you click on the Tile and set the 'Disable Main Hotspot'.

      Let me know if this makes sense!

      Delete
    3. This comment has been removed by the author.

      Delete
    4. Hi Sasank,

      Is there anyway that could disable hotspot dynamically through Peoplecode.

      Actually, I've written an app package which returns an HTML area for on a tile and also when clicked on it goes to a Nav Collection. On certain criteria, the tile should be disabled. Is there anyway I can achieve this?

      I'm not sure, if I can use a function or any sort of such to disable the tile.

      Thanks!



      Thanks@

      Delete
    5. I just see a property SetGroupletDisplayIn(). Is there any way we could use this in getTileLiveData function in App package

      Delete
    6. This comment has been removed by the author.

      Delete
  2. Hi Sasank, I am getting a error when attempting dynamic content on a tile...in step 3 of Tile Wiz when I tried to select my Content Ref, I am getting an error "There is no current buffer context." Have you seen this before? I traced it back to the SetCRefListArea function that uses Getlevel0() but somehow my new CF for the tile is blowing it up...have you seen this before or have you tried with a new CF instead an existing one? Thanks!

    ReplyDelete
    Replies
    1. Nevermind...the client had 8.55.08 tools on 9.1. I tried the same in 8.55.09 in 9.2 and it worked fine. Now applying patch for 8.55.15...

      Delete
    2. Ricky - Thanks for letting us know! Glad to hear that you figured it out.

      Delete
  3. Hi Sasank,

    Is there a way wherein if I click the tile, it will skip the search page of the component because the search fields will be populated already in the code.

    ex. Clicking tile1 will direct the user to component1 with institution1 as the search value. Clicking tile2 will direct the user to component1 with institution2 as the search value.

    ReplyDelete
    Replies
    1. When you say, "because the search fields will be populated already in the code"? To understand this correctly, can you explain what code you are referring to?

      You could pass the search key as a parameter in the CREF or CREF link. Then use different CREFs with different parameters for your search key and use them as your tile1 and tile 2 content.

      Delete
  4. How do we migrate the tiles to a project?

    ReplyDelete
    Replies
    1. You can use Data Migration Workbench to migrate Tile Wizard Tiles. PTPPB_GROUPLET is the delivered data set definition to migrate Tile Wizard data.

      Refer following document on My Oracle Support:
      E-FLUID : Migrate Fluid Tile (Doc ID 2213853.1)

      Delete
  5. Looks like there is an error with the above code.
    The error says: Inappropriate use of %Super. (2,83)

    Could you please suggest?

    ReplyDelete
    Replies
    1. Not sure what is causing this error.

      The code is based on this PeopleBook and I have not seen this error in 8.55. What tools version are you on?

      https://docs.oracle.com/cd/E66686_01/pt855pbr1/eng/pt/tpcr/task_ImplementingAnApplicationClassForTileContent.html?pli=ul_d57e1337_tpcr

      Delete
    2. I got the same error when I tried to copy paste this code (without changing the class name and constructor name in the code to match my class).

      Hope this helps. Thanks!

      Delete
  6. Hello Sasank,

    How do we copy a homepage of one user to another user?

    ReplyDelete
    Replies
    1. You could use the 'Publish Homepage' option to share a homepage created by one user to another.

      Refer:
      https://docs.oracle.com/cd/E66686_01/pt855pbr1/eng/pt/tprt/task_ManagingHomepages-c072ad.html#u551de682-b041-4373-a1a7-be78a1641a81

      Delete
  7. Hello Sasank

    Is there any way to create a tile that defaults for all users that links to a single peoplesoft component?

    ReplyDelete
    Replies
    1. Yes. You can add security to the Tile Content Reference to provide access to all users by picking a Permission List or Role that is available to all users. Alternatively, you could make the tile 'Public'.

      To the second part of your question. You can create a content reference or content reference link under PeopleTools > Portal > Fluid Structure and Content > Fluid Pages, and point that to the component you want the tile to link to.

      Hope this makes sense.

      Delete
  8. Hello Sasank

    We would also like to create a "Help" tile that links to a PDF file that we would host on our webserver. Is this possible?

    ReplyDelete
    Replies
    1. I have not tried this but it should be possible.

      Again, you will need to create a content reference (as an external link) under the Fluid Pages folder (in structure and content) and point to the pdf file.

      Delete
  9. Hi Sasank,

    First of all.. it works great!
    But when I put it into another environment, the user doesn't seem to have rights to see the live data on the tile. It seems like there is a security on the application class PTGP_APPCLASS_TILE.
    The component behind the tile is reachable, but the tile says: 'You are not authorized for this page.'

    Do you have any idea what this could be?

    ReplyDelete
    Replies
    1. @Jaimee-Lee Kleeman Very good question! I was clarifying this exact topic to my colleagues yesterday! :)

      Yes. There is actually an additional layer of security. When we use the tile wizard, we add the tile (CREF) to a folder under (Root > Fluid Structure and Content > Fluid Pages) in step 3 of the activity guide. In my example above, my tile CREF object name is TTS_UNIT_TEST and it resides in 'PeopleSoft Applications' folder (parent).

      Even though we have access to the underyling component, we also need to have access to this Tile CREF contained with 'Fluid Pages' sub folders. Basically, we need to go to this CREF object and add the appropriate roles/PL to this CREF using the 'Security' tab.

      Let me know if this works/makes sense. Thanks!

      Delete
  10. Hi Sasank,

    I have found the problem. We have a very strict security and the logged user didn't had access to the PTGPLT_APP_TILE_FL component (This is the component of the LiveData).

    So I was very confused because everything seemed to be ok according to your response.

    Thank you anyway!

    ReplyDelete
    Replies
    1. Yes. I totally forgot about that component. So, there is another layer of security if we are using dynamic tiles using Tile Wizard API!

      Thank you for this information. I am sure this will be useful for others.

      Delete
  11. hello Sansank, I'm using SetGroupletDisplayIn() to enable a tile through Peoplecode, it is not changing the mouse pointer to little pointer symbol. It is showing as arrow only and not the little hand pointer. Is there any setting or any property which would assign this?

    Thanks!

    ReplyDelete
    Replies
    1. I am not sure. I have not used that property. You may want to reach out to Oracle Support for clarification.

      Delete
    2. I am not sure if we can do that using the Tile Wizard API. I don't see any property/method that fits your requirement.

      You may want to contact Oracle Support and/or post your question in the My Oracle Support Community, in case anyone has additional ideas:
      https://community.oracle.com/community/support/peoplesoft/peopletools_-_psft

      Thanks!

      Delete
  12. Hi Sasank,

    I have requirement to perform transactions based on the Home Page that the user is on, in Classic %HPTabName will give me the Home page Information from which we can base our logic to work.

    Now in Fluid, the home page is always being DEFAULT. Is there any functions specific for finding the Fluid Homepage or a way in which we can have the above logic framed ?

    Any Help would be much Appreciated !

    Thanks in advance.

    ReplyDelete
    Replies
    1. Take a look at this post:
      https://pe0ples0ft.blogspot.com/2017/11/deep-linking-to-a-fluid-homepage.html

      This may not be directly a solution for you but hope you can build your logic based on the information in this post.

      Delete