Friday, April 14, 2017

Fluid UI - Tile Wizard API - Part 2 - Dynamic Tile Images

This post is a continuation of my previous article on the Tile Wizard API, where I described how we can use the Tile Wizard API to dynamically update the Tile Content.

In this post, we will see how we can use the Tile Wizard API for another similar and more common use case to display a dynamic image based on certain conditions.

For the purposes of this post, let us assume that we want to create a Tile called 'My Team' that displays a different image and live data based on the user's security role assignment.

Demo:


Tile Wizard Setup:

NavBar > PeopleTools > Portal > Tile Wizard > Create Tile






App Package PeopleCode Implementation:



PeopleCode for Reference:

import PTGP_APPCLASS_TILE:Tiles:Tile;

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

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

method getTileLiveData
   /+ Extends/implements PTGP_APPCLASS_TILE:Tiles:Tile.getTileLiveData +/
  
   If IsUserInRole("SV_CSK") Then
      rem %This.setTileImageRef("SV_CSK"); /* Method equivalent */
      %This.ImageReferenceField.Value = Image.SV_CSK;
      /* Live Data */
      %This.TileLiveData_1 = "Chennai Super Kings";
   End-If;
  
   If IsUserInRole("SV_RCB") Then
      rem %This.setTileImageRef("SV_RCB"); /* Method equivalent */
      %This.ImageReferenceField.Value = Image.SV_RCB;
      /* Live Data */
      %This.TileLiveData_1 = "Royal Challengers Bangalore";
   End-If;
  
end-method;

22 comments:

  1. Replies
    1. Refer following document on My Oracle Support:

      E-FLUID : Migrate Fluid Tile (Doc ID 2213853.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.

      Navigation : Peopletools -> Lifecycle Tools -> Migrate Data -> Data Migration WorkBench

      Delete
  2. Where are the images - Image.SV_CSK and Image.SV_RCB placed?

    I am trying to do the example stated here; so would like to know the place where these images are placed?

    ReplyDelete
    Replies
    1. I uploaded the images (SVG format) using the Branding Objects page.
      PeopleTools > Portal > Branding > Branding Objects (Images)

      Delete
  3. We have created a custom tile that just displays few external links into it. But we are noticing that Image link and the description are not coming up in the same line. Any thoughts ?

    ReplyDelete
  4. Hi Sasank, thank you for this tutorial, it's awesome.
    I have a question, is it possible to add a hyperlink to a tile to point to different external page then the tile itself? For example can you make "Royal Challengers Bangalore" a hyperlink instead of just plain text?

    ReplyDelete
    Replies
    1. You could set the Tile content as HTML using SetTileContentAsHTML and then manipulate the HTML using the App Class PeopleCode.

      Delete
    2. You can review this post which might give you another option:
      https://pe0ples0ft.blogspot.com/2018/09/tile-wizard-api-dyn-target-page.html

      Delete
  5. Hello Shashank,

    This is really knowledgable :)
    Initially i used a Free Text as the source and in the source I gave a Video Link , for ex-A you tube link.
    When the Tile is displayed on the Home page, User can play the Video on the tile.
    But My Question is :-
    Now I want to use different Video based on different Roles.
    Lets say If I login-I should see You Tube Video ABC and If My Manager Logs in, he should see Video DEF of you tube.
    You have Told us about the images based on roles, about the target content based on roles but can this video thing be achieved?

    ReplyDelete
    Replies
    1. Hi Sumit,

      I have used Event Mapping on the PT_LANDINGPAGE Activate event to dynamically change the content of a tile in such scenarios.

      The concept is very similar to a trick which I learned on this thread:
      https://community.oracle.com/thread/4052095#thread-message-14430289

      Delete
    2. Sorry - I meant PT_LANDINGPAGE.PostBuild component peoplecode event.

      Delete
    3. Hello Sasank,

      Today Only I achieved what I was asking you but in a diff way and the way is what you suggested by using SetTileContentAsHTML.
      I used this function and then i used %This.TileHtmlArea property to define diff You tube Links based on Roles.Something Like this:-
      If IsUserInRole("DSX_Sumit") Then

      %This.TileHtmlArea = GetHTMLText(HTML.TEST_HTML_SUMIT);

      %This.TileLiveData_1 = "You are DSX_Sumit";

      End-If;

      If IsUserInRole("DSX_Sumit1") Then

      %This.TileHtmlArea = GetHTMLText(HTML.TEST_HTML_SUMIT1);

      %This.TileLiveData_1 = "You are DSX_Sumit1 ";
      End-If;


      And It worked too :) So your earlier suggestion also worked.

      Delete
  6. Please do you have example on Pivot Chart to be displayed dynamically on PS Tile. Preferable chart having bind values.

    ReplyDelete
    Replies
    1. Unfortunately, I don't have an example that I can share with you right now.

      Delete
  7. Hi Sasank, Can we change the title of the live tile based on the role assigned t the user?

    ReplyDelete
    Replies
    1. In the above example I want to change "My Team" based on user role

      Delete
  8. Hi, Can we change the title of the live tile based on the role assigned to user?

    ReplyDelete
  9. Hi , I know we can change TileImageReferenceLabel . but I am looking to change the tile title."My Team" in above example

    ReplyDelete
  10. You cannot use tile api for that.

    You could try using event mapping on the homepage and try manipulating the tile title.
    https://community.oracle.com/thread/4052095#thread-message-14430289

    I have not tried this so I cannot confirm if it will work or not.

    ReplyDelete
  11. Can we set custom images to delivered tiles without updating the image property on tile using event hi, mapping framework?

    ReplyDelete
  12. Hi, can we set custom images to delivered tiles without modifying the CREF property and using Event mapping Framework?

    ReplyDelete
    Replies
    1. You can use Event Mapping on the Landing Page to reference a different image.

      This post should give you an idea on how to go about it (not the exact same requirement):
      https://community.oracle.com/thread/4052095#14430289

      Delete