function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
brozinickrbrozinickr 

Redirect to Parent on save for the Child Record

I have a custom button on an parent object called SMART__c.  The child to this object is Monthly Objective.  Basically when I save the record on the child, Monthly Objective, I want to be able to redirect the user to the parent record (SMART) of the child.

So basically, when I create a Monthly Objective and click save, I want to be directed to the related SMART record.

Is this possible with just URL hacking or do I need to do custom visualforce?

Thanks,

Rachel
satyadev1.3920959284801863E12satyadev1.3920959284801863E12
Hi,

Yes you can do it via url hacking. Just pass the parent id as

saveURL=%2F[Parent Id] in the url.

Thanks,
Satyadev
Mark M.Mark M.
Thank you!
I tried the following code.  WIth no success.  I believe it is because I am attempting to hard code the ID.  

<apex:sectionHeader description="This is the header of the section that you are about to edit.  It contains many items that you will need to know."/>
          <apex:pageblock mode="edit" title="{!$ObjectType.Monthly_Manager_Objectives__c.label} Edit">
          <apex:sectionHeader description="This is the header of the section that you are about to edit.  It contains many items that you will need to know."/>
            <apex:pageblockbuttons >
                <apex:commandbutton value="Save" action="{saveURL=%2F[a4Bf00000005Krd]}"/>
                <apex:commandbutton value="Cancel" action="{!Cancel}"/>
            </apex:pageblockbuttons>
            <apex:outputpanel >

Any advice?
satyadev1.3920959284801863E12satyadev1.3920959284801863E12
Hi Mark,

'saveUrl=%2Fa4Bf00000005Krd' should be there in browser url not in action parameters of commandbutton.

Add this paremeter in the browser Url as '&saveUrl=%2Fa4Bf00000005Krd'. And in action parameter of commandButton write as below:-
<apex:commandbutton value="Save" action="{!save}"/>


If you are using custom controller for this vf page then you can create a pagereference return type method in class as

public pagereference redirectUrl(){
pagereference pf= new pagereference('/'+parent.id);
return pf;

and then you can change your commandbutton action as
<apex:commandbutton value="Save" action="{!redirectUrl}"/>

Hope this will help you.

Thanks,
Satyadev