@LionSolution, Thanks, I did’t have any panels in some of the tabs. I did took another path. Its a bit more more complicated but it allows me to not rely on tab numbers. I added hidden fields into each tabs tab-content section. If someone knows another way of adding hidden fields I would like to know how to do that.
Not sure if anyone can use this but here’s what I did.
Purpose:
I needed to populate fields on a new Case from our billing system. The billing system needs to know what type of service I needed to pull data from. Our billing system uses fixed fields for data and depending on the service you are requesting, the fields contain different data. This was the reason I needed to know what each tab was for.
I added some non-db type fields with some customCode to insert a hidden field and then using studio I added these fields to each tab.
So in custom/Extension/modules/Cases/Ext/Vardefs I added a file named case_tabs.php.
In this file I added several variables:
$dictionary['Case']['fields']['hiddentab_iptv'] = array(
'name' => 'hiddentab_iptv',
'vname' => 'hiddentab_iptv',
'type' => 'hidden',
'source' => 'non-db',
'studio' => 'visible',
'inline_edit' => false,
'customCode' => '<input type=\'hidden\' name=\'tab\' value=\'iptv\' />',
);
I changed the name, vname and customCode value for each type of hidden field I wanted to add.
I used JavaScript to hide these div’s upon document.ready():
$("div[data-field^='hiddentab']").hide(); // Hides hiddentab
$("div[data-field^='hiddentab']").next().hide(); // Hides next empty div
Here is some code I used to post to the server. The purpose was to go grab data from our billing system to populate fields on a new Case.
if ($("input[name='record']")) {
if ($("input[name='record']").val() != "") {
// Existing Record so Load up data for each tab.
if ($("[name='bm_userid_c']").val() > 0) {
var tabs = {};
$("a[id^='tab']:visible:not(':first')").each(function () {
var tabnum = $(this).attr('id').match(/tab(\d)/)[1]; // Get Tab #
if (tabnum > 0) {
var arr = [];
$flds = $("#tab-content-" + tabnum + " div[field]").each(function () {
arr.push($(this).attr("field"))
});
$flds = $("div.tab-panel-" + tabnum + " div[field]").each(function () {
arr.push($(this).attr("field"))
});
var tabname = $("div#tab-content-" + tabnum).children().find('input[type="hidden"][name="tab"]').val();
if (arr.length > 0) {
var obj = {
"tab": (tabnum !== undefined) ? tabname : null,
"fields": arr
}
tabs[tabnum] = obj;
}
}
});
$.ajax({
method: "GET",
url: "/index.php?entryPoint=caseGetServices",
data: "get=getServiceData&userId=" + $("[name='bm_userid_c']").val() + "&data=" + JSON.stringify(tabs),
method: "POST",
type: JSON,
success: populateServiceData,
});
}
}
}
function populateServiceData(obj) {
$.each(obj.data, function (tab, fields) {
$.each(fields, function (fieldname, fieldvalue) {
$("[name='" + fieldname + "']").val(fieldvalue);
});
});
}
The caseGetServices entrypoint just pulls data back from the billing system.
Tony