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
Jim MontgomeryJim Montgomery 

getting redirected to Salesforce login page after location.href= in javascript

Code.
Getting sent to the login page on re-direct.

<apex:page standardController="Apttus_Proposal__Proposal__c"> <script src="/soap/ajax/10.0/connection.js"> </script > <script src="/soap/ajax/10.0/apex.js"> </script > <apex:iframe src="{!URLFOR($Resource.SAP_Order_Checklist)}" id="theIframe"/> <script type="text/javascript"> window.onload=init() function init() { var p = new sforce.SObject('Apttus_Proposal__Proposal__c'); p.Id = "{!Apttus_Proposal__Proposal__c.Id}"; p.sap_checklist_accessed__c = true; result = sforce.connection.update([p]); location.href="https://wktaatest--taatest.cs54.my.salesforce.com/"+p.Id }; </script> </apex:page>
Ashish KeshariAshish Keshari
Hi Jim,
If I understand your code directly - below is what your code is right ?
<apex:page standardController="Apttus_Proposal__Proposal__c"> 
    <script src="/soap/ajax/10.0/connection.js"> </script > 
    <script src="/soap/ajax/10.0/apex.js"> </script > 
    <apex:iframe src="{!URLFOR($Resource.SAP_Order_Checklist)}" id="theIframe"/> 
        <script type="text/javascript"> 
        window.onload=init() 
        function init() { 
            var p = new sforce.SObject('Apttus_Proposal__Proposal__c'); 
            p.Id = "{!Apttus_Proposal__Proposal__c.Id}"; 
            p.sap_checklist_accessed__c = true; 
            result = sforce.connection.update([p]); 
            location.href="https://wktaatest--taatest.cs54.my.salesforce.com/"+p.Id 
        }; 
        </script> 
</apex:page>
Just trying to understand it better - how are you invoking your VF page and also I guess you have registered a force.com domain and have created a site under it ? Login screen usually comes when you are trying to access a restricted page. 
 
Jim MontgomeryJim Montgomery
Basically this VF page is accessed from a formula with a hyperlink in it. I then run the iframe which downloads the excel file I have as a resource. Then, it runs the javascript to update fields on the record it came from and redirect back to the original page. I do it this way so it refreshes after the field update. Jim Montgomery Manager, Sales Intelligence Operations Wolters Kluwer Tax & Accounting 20101 Hamilton Ave. Torrance, CA 90502 877-346-7148 jim.montgomery@wolterskluwer.com