Different skuid pages for override of view action based on field value

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I'd like to override the standard View action for an object, but I want to point to different skuid pages depending on the value of a field in the object.

What's the best way to accomplish something like that? Conditional statements in the VF page?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Conditional statements in the VF Page is definitely an option. This would work for either the Redirect or Page Component approach for loading Skuid.

Depending on how different the pages are, Conditional Rendering might be a simpler option, but if the pages are radically different then I think Conditional statements in the VF override code would be simplest.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Thanks, Zach.

Yes... radically different.

I've been avoiding learning VF/APEX... (I've almost gotten away with completely avoiding it, thanks to how awesome skuid is!).
Anyone care to point me toward a place I can learn to write conditional statements in VF?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Ok.... now what if I want one of the options in my case statement to be "don't use a skuid page, use the standard SFDC layout instead"   ???
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Ok... I tried it out with the Page Component approach.

Here's my VF Page (just a few of the options for now):
<apex:page standardController="Interaction__c" extensions="skuid.Redirects"        showHeader="false" sidebar="false" readonly="true" docType="html-5.0"
        action="{!IF(canUseSkuid,'',redirect)}" title="{!Interaction__c.Interaction_Purpose__c}">
    <skuid:page page="
        {!CASE(Interaction__c.Interaction_Purpose__c,
            'Initial Pregnancy Appointment',    'InitialPregnancyAppointment',
            'Return Pregnancy Appointment',     'ReturnPregnancyAppointment',
            'Initial STD Appointment',          'InitialSTDAppointment',
            'Return STD Appointment',           'ReturnSTDAppointment',
            'Admin_Interactions')}" />
</apex:page>

Here's the error I'm getting when I attempt to view an interaction (one of the purposes I've defined):
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Matt, that's the error you get when Skuid couldn't find a page to display. Any chance that one of the page names you provided is not a valid Skuid Page name?
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
One thing you can do to debug what page is getting chosen is to add an additional tag to your page that just spits out the page that resulted from your case statement:

<apex:outputText value="
        {!CASE(Interaction__c.Interaction_Purpose__c,
            'Initial Pregnancy Appointment',    'InitialPregnancyAppointment',
            'Return Pregnancy Appointment',     'ReturnPregnancyAppointment',
            'Initial STD Appointment',          'InitialSTDAppointment',
            'Return STD Appointment',           'ReturnSTDAppointment',
            'Admin_Interactions')}" />
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Thanks, Zach.

The code is returning the right value:

and it is a legit Skuid page:

but I'm still getting the error.