last day (15 days later) » 

15:59
Hi Adrian. Thanks for your help. I opened my console and get this error message:
1015Uncaught {faultcode:'sf:INVALID_SESSION_ID', faultstring:'INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session', detail:{UnexpectedErrorFault:{exceptionCode:'INVALID_SESSION_ID', exceptionMessage:'Invalid Session ID found in SessionHeader: Illegal Session', }, }, }
Ah
try adding this to the beginning of your script
sforce.connection.sessionId = '{!$Api.Session_ID}';
Now I get 2 other errors:

Refused to set unsafe header "User-Agent"

Uncaught TypeError: Cannot read property 'reload' of undefined
16:17
hmm... which line is throwing that? window.location.reload or window.location.top.reload?
can you do console.debug(window.location) before that line?
I put that code before each window.location.top.reload() line in my script?
OK. It returns the following:

Uncaught TypeError: Cannot read property 'reload' of undefinedEscalate
Escalate @ servlet.Integration?lid=066L00000006JRH&ic=1&linkToken=VmpFPSxNakF4Tm‌​kwd05TMHlNVlF4Tmpvek1qb3dNaTR6…:37
onclick @ servlet.Integration?lid=066L00000006JRH&ic=1&linkToken=VmpFPSxNakF4Tmk‌​wd05TMHlNVlF4Tmpvek1qb3dNaTR6…:59
16:38
um
what line throws that error?
you need to make sure window.location.top is defined, so you should have a line like window.location.top
are you using this as an inline vf page on a page layout?
Yes, it is an inline VF page. Does that make a difference?
just verifying my assumption
It's a VF page acting as a button in a layout
first thing in the script, put console.debug(window.location.top)
does it give you a result?
I get a few things:
VM2262 connection.js:594Refused to set unsafe header "User-Agent"send @ VM2262 connection.js:594sforce.SoapTransport.send @ VM2262 connection.js:1013sforce.Connection._invoke @ VM2262 connection.js:1640sforce.Connection.invoke @ VM2262 connection.js:1579sforce.Connection.update @ VM2262 connection.js:1235Escalate @ servlet.Integration?lid=066L00000006JRH&ic=1&linkToken=VmpFPSxNakF4Tmkwd05TMHlNVlF4TmpvME16b3lOeTQz…:32onclick @ servlet.Integration?lid=066L00000006JRH&ic=1&linkToken=VmpFPSxNakF4Tmkwd05TMHlNVlF4TmpvME16b3lOeTQz…:58
Uncaught TypeError: Cannot read property 'reload' of undefined
Escalate @ servlet.Integration?lid=066L00000006JRH&ic=1&linkToken=VmpFPSxNakF4Tmkwd05TMHlNVlF4TmpvME16b3lOeTQz…:37
onclick @ servlet.Integration?lid=066L00000006JRH&ic=1&linkToken=VmpFPSxNakF4Tmkwd05TMHlNVlF4TmpvME16b3lOeTQz…:58
Unfortunately, I don't know what any of it means.
16:46
gah so much of what you're sharing is irrelevant
the only part that matters is the undefined line
but you shouldn't be getting that before your debug if you put it first thing in your script
try to do var location = window.location.top || window.location
and then do location.reload() instead of window.location.top.reload
Sorry, I don't know Javascript very well. This is what my script now looks like:
<script type="text/javascript">
console.debug(window.location.top);
var location = window.location.top || window.location
sforce.connection.sessionId = '{!$Api.Session_ID}';
function Escalate(){
var confirmMsg = confirm("Are you sure you want to escalate to the Client?");
var c = new sforce.SObject("Case");
if(confirmMsg == true){
c.id = "{!Case.Id}";
c.Escalate_to_Client__c = true;
sforce.connection.update([c]);
}
can you try the location variable i just recommended and see if that resolves it?
When I load the page, it now shows a copy of my page instead of the button image. This is my VF page:

<apex:form >
<center>
<apex:pageBlock mode="maindetail" >
<apex:pageBlockButtons location="Top" >
<div style="width:400px;">
<apex:commandButton style="background:#99EB99;" value="Escalate To Client" onClick="Escalate();" rendered="{!IF(Case.Escalate_to_Client__c = false, TRUE,FALSE)}"/>
<apex:commandButton style="background:#99EB99;" value="Rescind Escalation To Client" onClick="Rescind();" rendered="{!IF(Case.Escalate_to_Client__c = true, TRUE,FALSE)}"/>
um, the button doesn't even show up any more?
Never mind that 2nd part, I neglected to put the ; after the variable. The button does load and it looks like it does reload, but it appears that only the button (i.e., VF page reloads) and not the full page.
16:58
ok, comment out your entire script
the one thing i want to know
is console.debug(window.location.top)
is it undefined?
How do I put that line in my code? Do I need to enclose it in a script?
yes, it needs to be running inside javascript script tags
OK. I put that in and reloaded the page, but I don't get an error.
what does the debug tell you...
17:17
Sorry, where do I find debug?
in your console
do you have it open?
Yes. I see Elements, Console, Sources, Network, Timeline, Profiles, Resources, Security and Audits, but no Debug
go to the console tab...
console
that is where you get debugging information from js
OK. I think I found it. I see this:

##current_URL: https://cs8.salesforce.com/500L0000008BYv3IAG?nooverride=1
### Parent URL: https://cs8.salesforce.com/500L0000008BYv3IAG?nooverride=1
### Parent URL: -1
Service Cloud Toolkit API cannot be used with your browser.
undefined console.debug(window.location.top);
so you should see a little > character, right?
next to that type window.location.top and hit enter
are you in service console or anything like that?
17:30
Yes I see it. It comes back Undefined. No, I am in sandbox when running
you can visit the service console in a sandbox
it's just a normal page layout in the classic ui?
that's what i'm trying to get at
No, I'm just running on a standard Case page layout.
hmm, try using the code you had before but put window.location.top.reload() as the oncomplete instead
oncomplete
i think it just has to do with when you are calling it
17:46
So put oncomplete="window.location.top.reload()" instead of onclick?
well, you need that as your oncomplete attribute, yes
leave your onclick
but comment out the reload calls in your methods
So like this in my commandButton: onClick="Escalate();" oncomplete="window.location.top.reload()"
Still no luck, still showing as undefined
did you comment out all reference to window.location in your methdos?
methods*
18:04
yes
 
1 hour later…
19:10
Hey, I got it to work using onComplete="window.top.location = '/{!case.Id}';" in my button. Thanks for all your help!!

last day (15 days later) »