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
RyanYoung429RyanYoung429 

Edit Return URL in Visualforce Page

Hello!

I have some code for a VF page and the RetURL is home:

, [retURL='/home/home.jsp'],

How do i have it return to the record of the custom object that start the process?

Thanks so much,

Ryan
Ravi Dutt SharmaRavi Dutt Sharma
Hi Ryan,

How is the VF page opened? By click of a button or click of hyperlink? You can send a parameter in the url which will have the record id. In you controller you can retrieve the parameter by using below piece of code.
 
ApexPages.currentPage.getParameters().get('Id')

Let me know if this helps. Thanks.
RyanYoung429RyanYoung429
Even before that. I created this little VF page tp prevent deleting, then cloned it for another object and got this error:

"Invalid parameter for function URLFOR
Error is in expression '{!IF(Sales_Order__c.Status__c== 'Closed' || Sales_Order__c.Status__c== 'Terminated', NULL, URLFOR($Action.Sales_Order__c.Delete, $CurrentPage.parameters.id, [retURL='/home/home.jsp'], TRUE))}' in component <apex:page> in page slordeleteoverrides
"


Which is strane because it is the same exact page that was used on another custom object. Any idea what this means @Ravi?
RyanYoung429RyanYoung429
I put that in and now I am geting this error "Error: Syntax error. Missing ']'"

, [retURL=ApexPages.currentPage.getParameters().get('Id')], TRUE))}">
Ravi Dutt SharmaRavi Dutt Sharma
, [retURL='/'+ApexPages.currentPage.getParameters().get('Id')], TRUE))}">

Try this.
RyanYoung429RyanYoung429
Nope, still says it is missing a "]" weird!

<apex:page standardController="Sales_Order__c"
            action="{!IF(Sales_Order__c.Status__c== 'Closed' || Sales_Order__c.Status__c== 'Terminated', NULL, URLFOR($Action.Sales_Order__c.Delete, $CurrentPage.parameters.id, [retURL='/'+ApexPages.currentPage.getParameters().get('Id')], TRUE))}">
    <apex:pageMessage title="Unauthorized"
                        summary="This Sales Order is in in {!Sales_Order__c.Status__c  } status and cannot be edited!"
                        severity="ERROR"
                        strength="3">
    </apex:pageMessage>
</apex:page>
Ravi Dutt SharmaRavi Dutt Sharma
Sorry, my bad. Its currentPage() instead of currentPage
 
<apex:page standardController="Sales_Order__c"
            action="{!IF(Sales_Order__c.Status__c== 'Closed' || Sales_Order__c.Status__c== 'Terminated', NULL, URLFOR($Action.Sales_Order__c.Delete, $CurrentPage.parameters.id, [retURL='/'+ApexPages.currentPage().getParameters().get('Id')], TRUE))}">
    <apex:pageMessage title="Unauthorized"
                        summary="This Sales Order is in in {!Sales_Order__c.Status__c  } status and cannot be edited!"
                        severity="ERROR"
                        strength="3">
    </apex:pageMessage>
</apex:page>

 
RyanYoung429RyanYoung429
Hmmm, still getting that error when I put this in. I may just go with what I have. I don't want to cause you any trouble.

<apex:page standardController="Sales_Order__c"
apiVersion=""
                action="{!IF(Sales_Order__c.Status__c== 'Closed' || Sales_Order__c.Status__c== 'Terminated', NULL, URLFOR($Action.Sales_Order__c.Delete, $CurrentPage.parameters.id, [retURL='/'+ApexPages.currentPage().getParameters().get('Id')], TRUE))}">

        <apex:pageMessage title="Unauthorized"

                            summary="This Sales Order is in in {!Sales_Order__c.Status__c  } status and cannot be edited!"

                            severity="ERROR"

                            strength="3">

        </apex:pageMessage>

    </apex:page>
RyanYoung429RyanYoung429
It looks like it starts with "["RetURL" and then ends with TRUE))"}". Coudl that be the issue?
Ravi Dutt SharmaRavi Dutt Sharma
No, there issue with value specified in retURL. I think there is some other way to concatenate strings in VF. Below code works if I remove the concatination part.
 
<apex:page standardController="Sales_Order__c"
            action="{!IF(Sales_Order__c.Status__c== 'Closed' || Sales_Order__c.Status__c== 'Terminated', NULL, URLFOR($Action.Sales_Order__c.Delete, $CurrentPage.parameters.id, [retURL='/'], TRUE))}">
    <apex:pageMessage title="Unauthorized"
                        summary="This Sales Order is in in {!Sales_Order__c.Status__c  } status and cannot be edited!"
                        severity="ERROR"
                        strength="3">
    </apex:pageMessage>
</apex:page>

 
RyanYoung429RyanYoung429
Yeah it's not working. It simply will not return to the page where the Edit or Delete was started. I'll just count myself lucky to have what I have and move on. But thanks :-)