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
BRupholdtBRupholdt 

Retrieving the retURL in an S-control

I created a custom button to automatically edit a field and save the changes using the retURL and passing the form parameters.  It works great.  I then created a custom edit button on the object to specify which record type to use.  It works great but now the first button doesn't work.
 
I think the field values from the first S-control aren't being passed through the S-control of the custom Edit.  Is there a way to read the retURL passed to the Edit page?  If so, that would solve my problem as I could simply append it to the url to exit the page.  When I tried to do so, I only get a null value so I know either I'm not doing it right or it's not possible.
KaushikKaushik
    Hi,
Did you override the standard button?
You can also invoke the standard edit button in the custom edit button code.
Could you provide some more info?

Kaushik
BRupholdtBRupholdt

I did override the standard Edit button.  I'm doing this on Opportunities.  This works fine for keeping users without access from editing records based on the record type.

Here is the Edit button override:

userID = '{!$User.Id}'
adminID = 'omitted'
integrationID = 'omitted'
accountingID = 'omitted'
lockedRecordTypeID = 'omitted'
unlockedRecordTypeID = 'omitted'
recordTypeID = "{!Opportunity.RecordTypeId}"

editURL = "{!URLFOR($Action.Opportunity.Edit, Opportunity.Id, [retURL=URLFOR($Action.Opportunity.View, Opportunity.Id)],true)}"
viewURL = "{!URLFOR($Action.Opportunity.View, Opportunity.Id)}";

if(!( userID==adminID | userID==integrationID | userID==accountingID )){
  if (recordTypeID==lockedRecordTypeID) {
    alert("This order is locked for processing.\n\nHave Accounting reject the order for you.")
    window.parent.location.href = viewURL
  } else {
    window.parent.location.href = editURL
  }
} else
  window.parent.location.href = editURL

 

And here is the custom "Reject" button.   It worked until I made the custom Edit override.

window.parent.parent.location.href='/{!Opportunity.Id}/e?retURL=%2F{!Opportunity.Id}&opp11=Rejected&save=1';

I figure if I could access the retURL from the Reject button, I could pass it along to the regular edit page in the editURL variable of the first script.

Thanks for looking at this.  I had given up on anyone replying.

KaushikKaushik
Hi,
Did you try using URLFOR function for the reject button?
 
Try to see if this code can help.I usually use this to override buttons.I have passed the name field,you can pass the opp11 field


this.parent.location.href="{!URLFOR(  $Action.Opportunity.Edit  ,  Opportunity.Id  ,[retURL=URLFOR(  $Action.Opportunity.View  , Opportunity.Id ),Name="Test"],true )}";

 
Kaushik
 

Message Edited by Kaushik on 06-21-2007 03:24 PM

BRupholdtBRupholdt
Using the URLFOR() method does work, thank you.  I had opted not to use it since I wanted the logic on my custom Edit s-control to determine if the action was permissible.  Using URLFOR and bypassing the override also bypasses that bit of logic. 
 
However, when I thought about that, I realized I could simply add the same logic to the s-control for each custom button.  Since I didn't want to manage the same code in multiple controls, I used a snippet to handle the permissions check and the appropriate variables are assigned by the calling control. 
 
It all works out very nicely now, just in a different way than I had initially pictured it.  Thanks for the help.