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

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:

Would it be possible to Related_Person__c detail to redirect to something like this:

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

How would I set that up?

Any ideas on this one, friends?


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}&amp;page=PatientDetailPage&amp;Id="{!PatientId}"#tab_two" extensions="skuid.Redirects" standardController="Related_Person__c">

You could also do this as a direct link in your skuid pages (rather than using the redirect infrastructure)

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.

Hmm, I’m not quite getting the syntax right.

When I do this…

<apex:page standardController="Related_Person__c" action="{!redirect}&amp;page=PatientChart&amp;id={!Patient_Name__c}#related_person" extensions="skuid.Redirects"
 showHeader="false" sidebar="false" readonly="true" docType="html-5.0">

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}&amp;page=PatientChart&amp;id="{!Patient_Name__c}"#related_person" extensions="skuid.Redirects"
 showHeader="false" sidebar="false" readonly="true" docType="html-5.0">

I get the error:
Error: apex:page is required and must be the outermost tag in the markup at line 1 column 1

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">
function goToPatientPage(){
<body onload="gotoPatientPage();">
<img src="loading.gif"> Redirecting    <----- this is completely optional


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…

Can you try instead of {!Patient_Name__c} put  {!Related_Person__c.Patient_Name__c}

That worked! I was able to go back to the direct approach Rob suggested, but using {!Related_Person__c.Patient_Name__c}

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?

The dirty workaround works! :slight_smile:

Sorry for the dirty workaround.  Thanks for your persistence.  Glad it works.