3

I have created a custom button and added it to a console application. What happens is when a particular profile user do not do any activity then after 10 to 15 minutes on clicking the custom button user is redirected to dashboard.Also , when I return to the same page again I got a pop up on button click i.e problem with on click javascript. Invalid _session_ID fault code: invalid session.

{!requireScript("/soap/ajax/29.0/connection.js")} 

var oppid = '{!Opportunity.Id}'; 
var get = null; 
var cases = null; 
var openCase = null; 
var caseNumber = null; 
var caseId = null; 

var result = sforce.connection.query("SELECT Case__r.Id, Case__r.Status, Case__r.CaseNumber FROM Opportunity WHERE (Id = '{!Opportunity.Id}' AND Case__r.Status != 'Closed')"); 

if(result != null || typeof result != 'undefined') 
{ 
get = result.getArray('records')[0]; 

if( get != null || typeof get != 'undefined') 
{ 
cases = get.getArray('Case__r'); 

if(cases == null || typeof openCase == 'undefined' || cases.length == 0){ 
srcUp('/apex/LogACallVSFPage?opportunitid='+oppid); 
} else if(cases.length > 1){ 
alert('There are multiple open cases on this loan. Please choose a case to log your call on.'); 
} else { 
openCase = cases[0]; 

if(openCase != null || typeof openCase != 'undefined'){ 
caseNumber = openCase.get('CaseNumber'); 
caseId = openCase.get('Id'); 
} else { 
alert('An error occured. Please contact your administrator.'); 
} 

if( (caseNumber != null || caseNumber != 'undefined') && (caseId != null || caseId != 'undefined')){ 

if(confirm('There is an open case on this account. Please Go to Open Case ' + caseNumber + ' to Log the Call.')== true){ 
srcUp('/' + caseId); 
} 
} else { 
alert('An error occured. Please contact your administrator.'); 
} 
} 

} else { 
srcUp('/apex/LogACallVSFPage?opportunitid='+oppid); 
} 

} else { 
alert('An error occured. Please contact your administrator.'); 
}

Please help me as I am also debugging the issue. It happens for a particular profile only.

1
  • Does this profile has access to the VisualForce page ?
    – Jarvis
    Jan 25, 2016 at 16:29

1 Answer 1

2

After

{!requireScript("/soap/ajax/29.0/connection.js")} 

Add

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

This will solve your session-timeout-error issue

6
  • I am just implementing and testing in UAT will update and mark as answer :) Jan 26, 2016 at 15:16
  • Its not working . Testing again :( Jan 27, 2016 at 22:48
  • @cloudlover are you still facing invalid session issue.. I believe you are facing other issue not invalid session issue ?
    – Ratan Paul
    Jan 28, 2016 at 5:14
  • Hi @ratan the org session timeoutvalue is 12 hr , when user do nothing in console vf page then he get redirected to homepage.For this particular instant VF session in session management is set to 15 minutes. It expire beyond that.Is the issue have any relation , Can we increase the VF session? Jan 29, 2016 at 21:21
  • @cloudlover may be you are facing this known issue. check this out success.salesforce.com/issues_view?id=a1p300000008ZO5AAM Currently salesforce fixing this issue.
    – Ratan Paul
    Jan 30, 2016 at 3:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .