Redirect standard salesforce view of child object to skuid page of parent

Matt SonesMatt Sones ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
edited July 1, 2019 in Questions
Related_Person__c is a child object of Patient__c.

When a user visits the detail page of a Related Person (i.e. /{{Id}}), I'd like to send them to the same squid page that the Patient detail redirects too, and also add #related_person to the url.

Patient__c detail redirects to something like this:
/apex/UI?id={{Id}}&sfdc.override=1&objectType=Patient__c&actionType=View

Would it be possible to Related_Person__c detail to redirect to something like this:
/apex/UI?id={{Patient_Name__c}}&sfdc.override=1&objectType=Related_Person__c&actionType=View#related_person

Where Patient_Name__c is the reference field from Related Person to Patient.

How would I set that up?

Comments

  • Matt SonesMatt Sones ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited February 10, 2017
    Any ideas on this one, friends?
  • Matt SonesMatt Sones ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited February 10, 2017
    ^^
  • Rob HatchRob Hatch ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited September 1, 2016
    Interesting challenge. ย 

    I think you can do this in your object / action override code, if you use the Skuid Redirect method and don't run the page through Page Assignments.ย 

    I think your VF Page code for View under Related_Person__c would look something like this:ย 
    <apex:page action="{!redirect}&page=PatientDetailPage&Id="{!PatientId}"#tab_two" extensions="skuid.Redirects" standardController="Related_Person__c">
    </apex:page>
    ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย ย 
    You could also do this as a direct link in your skuid pages (rather than using the redirect infrastructure)ย 

  • Matt SonesMatt Sones ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited February 10, 2017
    Thanks, Rob. I'll try it out. I would use the direct link idea, but the search component doesn't allow different actions for different objects.
  • Matt SonesMatt Sones ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited February 10, 2017
    Hmm, I'm not quite getting the syntax right.

    When I do this...
    <apex:page standardController="Related_Person__c"ย action="{!redirect}&page=PatientChart&id={!Patient_Name__c}#related_person" extensions="skuid.Redirects"
    ย showHeader="false" sidebar="false" readonly="true" docType="html-5.0">
    </apex:page>
    ย I get the error:
    Error: Unknown property 'Related_Person__cStandardController.Patient_Name__c'

    If I put quotes around {!Patient_Name__c} as your example suggests...
    <apex:page standardController="Related_Person__c"ย action="{!redirect}&page=PatientChart&id="{!Patient_Name__c}"#related_person" extensions="skuid.Redirects"
    ย showHeader="false" sidebar="false" readonly="true" docType="html-5.0">
    </apex:page>
    I get the error:ย 
    Error: <apex:page> is required and must be the outermost tag in the markup at line 1 column 1
  • edited July 1, 2019
    Maybe # is not a valid character to use in the action parameter...

    dirty workarround: Javascript
    <apex:page standardController="Related_Person__c" showHeader="false" sidebar="false" readonly="true" docType="html-5.0">
    <html>
    <head>
    <script>
    function goToPatientPage(){
    document.location='/apex/skuid__ui?page=PatientChart&id={!Patient_Name__c}#related_person';
    }
    </script>
    </head>
    <body onload="gotoPatientPage();">
    <img src="loading.gif"> Redirecting ย  ย <----- this is completely optional
    </body>
    </html>
    </apex:page>
  • Matt SonesMatt Sones ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited July 1, 2019
    Pablo,

    Thanks for the answer. I'm still getting this error code:

    Error: Unknown property 'Related_Person__cStandardController.Patient_Name__c'

    I really don't know much about apex at all... Skuid has largely shielded me from it (yay, skuid!). Is there something wrong in my syntax? Should {!Patient_Name__c} return the value of the Patient_Name__c field in the Related_Person__c object?

    Why am I seeing 'Related_Person__cStandardController' in the error message... as one word?

    I tried to look up some apex syntax on the SFDC help, but the help seems to be broken at the moment...

  • edited December 14, 2016
    Can you try instead ofย {!Patient_Name__c} put ย {!Related_Person__c.Patient_Name__c}
  • Matt SonesMatt Sones ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited February 10, 2017
    That worked! I was able to go back to the direct approach Rob suggested, but using {!Related_Person__c.Patient_Name__c}
  • Matt SonesMatt Sones ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited February 10, 2017
    Hmm, I spoke too soon. I was finally allowed to save the VF page... but when I implemented it as the view action this is what I get:

    SObject row was retrieved via SOQL without querying the requested field: Related_Person__c.Patient_Name__c

    Should I go back the the javascript method?

    Or is there a way to tell apex to query that field?
  • Matt SonesMatt Sones ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited February 10, 2017
    The dirty workaround works! :)
  • Rob HatchRob Hatch ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited September 1, 2016
    Sorry for the dirty workaround. ย Thanks for your persistence. ย Glad it works.ย 
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!