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);
}