0

I have a button that needs to open in the Service Console, and here is my javascript, any ideas? This is a new error and I am not sure how to handle, that is stopping a lot of activities

Error

Cannot read property 'getEnclosingPrimaryTabId of undefined

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} 

try { 
var query = "SELECT Id,Name,Contact__r.Name FROM TripProfile__c WHERE Trip__c = '{!Trip__c.Id}'"; 
var tripprofile = sforce.connection.query(query); 
var tripProfileArr = tripprofile.getArray("records"); 
if(typeof tripProfileArr === 'undefined' || tripProfileArr.length === 0 ) 
{ 
alert('There is no Trip Profile built yet'); 
}else if (typeof(srcUp) === 'function'){ 
var url = '/apex/tripprofile?tpid=' + tripProfileArr[0].Id; 
var callOpenSubtab = function callOpenSubtab(result) { 
sforce.console.openSubtab(result.id, '/apex/tripprofile?tpid=' + tripProfileArr[0].Id + '&isdtp=vw', true, 'TP - ' + tripProfileArr[0].Contact__r.Name); 
} 
sforce.console.getEnclosingPrimaryTabId(callOpenSubtab); 
} else { 
var url = '/apex/tripprofile?tpid=' + tripProfileArr[0].Id; 
window.open(url); 
} 
} catch (e) { 
alert(e); 
}
3

sforce.console is in the Console Integration Toolkit's script along with that method you're trying to call: getEnclosingPrimaryTabId.

It looks like you're only loading the Ajax Toolkit. (connection.js & apex.js)

If you add the console integration toolkit to your button, you should be good to go.

{!REQUIRESCRIPT("/support/console/34.0/integration.js")}

https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.