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
Pooja ShahPooja Shah 

Redirecting to the contract page in S control

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <script type="text/javascript" src="/js/functions.js"></script>
    <script src="/soap/ajax/12.0/connection.js"></script>
    <script>
 
function redirectToContractSummary()
{
    //Retrieving values about the current contract.
    var clickingUser = sforce.connection.getUserInfo();
    var currentContractId = "{!Contract.Id}";
    var contractResults = sforce.connection.query ("select Id, RecordTypeId from Contract where Id = '" +currentContractId+ "'");
    var contractRecords = contractResults.getArray("records");
    var createdBy = "{!Contract.CreatedBy}";
    var UserId = "{!User.Name}";
    
    if (contractRecords[0].RecordTypeId == '012T0000000CmwkIAC')
    {
        
        this.parent.top.location.replace("/apex/contract_summary?contractId="+currentContractId);
        }
    else if (contractRecords[0].RecordTypeId == '012700000000vXAAAY')
    {
       
        this.parent.top.location.replace("/"+currentContractId);
        
    }        
}
redirectToContractSummary();
    </script>
</head>

<body>
</body>
</html>

This gets into an infinite loop because of 
this.parent.top.location.replace("/"+currentContractId) if i change the url here to something /apex/_____ then it works.
I want to redirect it to the default contract view page.
Any ideas how that can be achieved.

Last option is that i recreate a visual force page identical to the contract view page and direct it there.


pooja
werewolfwerewolf
Is this an inline Scontrol on the Contract page?  If so, then just remove it from the page layout of that second record type that's sending you into an infinite loop.
mtbclimbermtbclimber
Assuming that you've overridden the standard view action for contract with this scontrol you can force the user to the standard view page (bypassing your override) if you switch to using the supported mechanisms for generating URLs to standard pages in the application, i.e. using the URLFOR function along with the appropriate $Action global since that function supports an optional override argument:

{!URLFOR(target, id, [inputs], [no override])}

See the online help for more information about URLFOR, $Action and other formula functions/globals.

Note: You should not be relying on salesforce.com URL patterns, parameter names or DOM IDs as they are subject to change at any time.