Friday, September 21, 2018

Tile Wizard API - Part 4 - Dynamic Target Page

I previously wrote a series of posts on Tile Wizard API which allows us to control the display of the Tile Content using PeopleCode.

Part 1: Dynamic Tile Content
Part 2: Dynamic Tile Images
Part 3: Dynamic Tile Styling

These posts mainly focused on the content of the Tile as expected because the Application Class delivered by Oracle was mainly for the purpose of manipulating 'Tile Content'.

Marcin Tomczak asked the question:
"Can we make the tile point to a different external page than the tile itself?"

This made me wonder if we can dynamically change the target/destination page (internal/external) of a tile using PeopleCode? It is technically not a feature as per the design/implementation of the Tile Class. But there is an error/exception processing option that is available which might enable us to "hack" the Tile Class to do something it was not originally intended for.

Tile Class Properties - hasContent
Tile Class Properties - PreferencesURLLabel
Tile Class Properties - PreferencesURL

The hasContent property allows us to enable the error/exception mode where we can set a different image, destination URL and URL label. While it is technically not an error scenario in this case, we can still set it in error/exception mode to dynamically modify the Tile destination/target page!

Demo

- As you can see in the demo, the Tile 'Dynamic Target' is created using Tile Wizard with a destination page as 'My System Profile'. This destination has no significance because the 'Disable Main Hotspot' is set to 'Yes'.
- Once the role 'SV_ROLE_1' is added to PS user, we can see the new image and 'My Preferences' URL is enabled for the 'Dynamic Target' tile via the Tile App Class.
- When the role is switched to 'SV_ROLE_2', we can see the 'Change My Password' URL is enabled for the 'Dynamic Target' tile via the Tile App Class.
- When the role is switched to 'SV_ROLE_3', we can see the 'Google Search' external URL is enabled for the 'Dynamic Target' tile via the Tile App Class.


 Tile Wizard Settings








App Package PeopleCode


Environment Details
- CS 9.2 PUM Image 4
- PeopleTools 8.55.12

14 comments:

  1. Hello Sasank,

    This is a really nice post where we can have just 1 tile and different Targets with diff Roles.
    Much better than creating Multiple Tiles and attaching them to diff roles.

    I tried and yes we can have different tile Image, tile Video, Tile Styles and diff Targets based on roles BUT I have 1 question:-
    Can we also have different Tile Titles based on Roles.This is because a user would want to see a different Tile Title based on Roles.

    ReplyDelete
    Replies
    1. Tile Title is not a property of the Tile class and therefore it cannot be updated using PeopleCode (App Class).

      Refer: https://docs.oracle.com/cd/E99483_01/pt857pbr1/eng/pt/tpcr/concept_UnderstandingApplicationClassTileContent.html?pli=ul_d57e1390_tpcr

      But for sure cases, like I said my previous comment, I would recommend using Event Mapping.
      Refer: https://pe0ples0ft.blogspot.com/2017/04/fluid-ui-tile-wizard-api-part-2.html?showComment=1542641883770#c5360543208072817180

      Delete
  2. Hi Sasank,

    Is there a way to remove the border of the image when using the following? I get a border around the image every time I use the code.

    %This.hasContent = False;

    %This.ImageReferenceField.Value = Image.CSK_LOGO_32;

    /* Set Destination URL - Label and Value */

    %This.PreferencesUrlLabel = "Google Search";

    %This.PreferencesUrl = "https://www.google.com";

    ReplyDelete
    Replies
    1. Yes.

      In the app package, include the following lines of code within the SV_ROLE_3 if clause:
      %This.TileID = "SV_TILE_ID";
      %This.TileSpecificStyleSheet = StyleSheet.SV_TILE_CSS;

      Create a Style Sheet object SV_TILE_CSS with following code:
      https://gist.github.com/SasankVemana/e767d00af7c65e373be3825a0b3f3a86

      This will override the border that you want to remove. The border is generated originally as part of PTGP_HOME_TILE_FL style sheet.

      This implementation is based on one of my previous posts:
      https://pe0ples0ft.blogspot.com/2017/04/fluid-ui-tile-wizard-api-part-3.html
      - Review Scenario 2

      Delete
  3. Hi Sasank,When you using your sample code I get the a border around the image is there a way to remove the border around the image?

    %This.hasContent = False;

    %This.ImageReferenceField.Value = Image.CSK_LOGO_32;

    /* Set Destination URL - Label and Value */

    %This.PreferencesUrlLabel = "Google Search";

    %This.PreferencesUrl = "https://www.google.com";

    ReplyDelete
  4. 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 of that particular topic. I will let you know if I do.

      Delete
  5. Hello Henry, I also had the same problem. I fixed that and other formatting issues to make the tile look 'normal' by using Sasank's suggested post with the css included below. What I HAVEN'T been able to do is to remove/replace the hover text 'URL Link' and was wondering whether you may have found a way to do this ?

    .TILE_ID_CLASS .psc_tile-hotspot .psa_tile-hotspot-link > .ps-link-wrapper {
    border-style: none;
    }

    .TILE_ID_CLASS .psc_tile-hotspot .psa_tile-hotspot-link > .ps-link-wrapper > .ps-link:hover {
    background: none;
    }

    .TILE_ID_CLASS .psc_tile-hotspot .psa_tile-hotspot-link > .ps-link-wrapper > .ps-link > .ps-text {
    display: none;
    }

    ReplyDelete
  6. Hi Sasank, I have created live tile which is targeting to the different pages. For 1 target page we have to point to the URL of the delivered tile. In the above example My Preferences' URL is enabled for the 'Dynamic Target' tile via the Tile App Class. How can I generate URL for delivered tile? right now I am passing full browser URL in double quote but it can change in each instance

    ReplyDelete
  7. Hello, this is neat and I am about to launch a tile that uses this if statement to take people to different target locations based on their data. Thank you! Question for you - do you know of a way to launch the employee to the middle of a nav collection using code that sets %This.PreferencesUrl?

    The nav collection has a pending link and a view link. If they have a pending item I want to launch to the pending link with the nav collection, if not then launch them to the view link.

    The links in the nav collections are query links (if that matters) not specific component/menu.

    Thanks and appreciate your posts!

    ReplyDelete
    Replies
    1. Hi Rajani - You might want to take a look at this post:
      http://blog.jsmpros.com/2019/05/launching-into-middle-of-fluid.html

      You can use this approach to deeplink into a URL within the Nav Collection.

      Delete
  8. Hi Sasank, Always appreciate your blogs and had a lot of luck with this one! We used this to create a tile that links to an external page. We didn't need to manage the URL conditionally necessarily but we did need an App Package to create PeopleCode that would build that URL as it is unique to each user/student.
    What we are seeing is that despite our Tile Display Properties being set to "Display In: New Window" for this tile that is associated to an App Package, it does not actually open a new window when clicked. Do you know of any other way to control this New Window behavior for a tile? Thanks much!
    Jami Kong

    ReplyDelete
    Replies
    1. Hi Jami,

      This is interesting. I am assuming the TILE API option is ignoring the Tile Display Properties which is understandable. However, I don't see anything in the TILE Class that will allow us to 'open in a new window'.

      Only thing I can think of right now is to use the SetTileContentAsHTML function and then write your own HTML code (with anchor tag, etc.) to set the TileHtmlArea property.

      I have not tried this yet but i am hoping it would work. Let me know what you find!

      Delete