+ Start a Discussion
YashavantYashavant 

Invalid Session Id

Hi,

I am getting invalid session id for following code:

I have called Parent Window: updateRecord() function from child window.

Code:
<apex:page >
<HTML><HEAD><script src="/soap/ajax/14.0/connection.js"></script><script src="/soap/ajax/14.0/apex.js"></script>
 </HEAD>
<SCRIPT LANGUAGE="JavaScript">
    function openChild(file,window1) {
        var childWindow=window.open('','name','height=400,width=500');
        if (childWindow.opener == null){ 
            childWindow.opener = self;
        }else{
            childWindow.document.write('<FORM NAME="childForm"  >');
            childWindow.document.write('<BR>To      :<INPUT NAME="cf1To" TYPE="TEXT" VALUE="" size="60">');
            childWindow.document.write('<BR>CC      :<INPUT NAME="cf2Cc" TYPE="TEXT" VALUE="" size="60">');
            childWindow.document.write('<BR>Subject :<INPUT NAME="cf3Subject" TYPE="TEXT" VALUE="" size="60">');
            childWindow.document.write('<BR><INPUT TYPE="button" VALUE="Submit" onClick="javascript:{alert(\'hi\');alert(\'Cf1To :\'+document.childForm.cf1To.value);;opener.document.parentForm.pf1.value = document.childForm.cf1To.value; window.opener.updateRecord();self.close();return false;}">');
            childWindow.document.write('</FORM>');
            childWindow.document.childForm.cf1To.value='yashavant_b@abc.in';
            childWindow.document.childForm.cf2Cc.value='manjiri_y@abc.co.in';
            childWindow.document.childForm.cf3Subject.value='Confirmation';
        }
     }
     function updateRecord(){
        try{
            var success = sforce.apex.execute('EmailTestWebServiceClass','updateEmailTest',{a:'abc'}); 
        }catch(e){
            alert('Exception='+e);
        }
     }
</SCRIPT>

<BODY>
<FORM NAME="parentForm">
<INPUT TYPE="button" VALUE="Open child" onClick="openChild('examplejs2.html','win2')">
<BR><INPUT NAME="pf1" TYPE="hidden" VALUE="">
<BR><INPUT NAME="pf2" TYPE="TEXT" VALUE="">
</FORM>
</BODY></HTML>

</apex:page>

 Any pointer on this will be helpful.

Yash

MohanaGopalMohanaGopal

HI..

Try this...

    It may help u

 

sforce.connection.sessionId='{!$Api.Session_ID}';