Howdy!
I think you can probably do that using some JavaScript
To count the number of times a tab is clicked on, you can use the tabStateChange event handler to execute a JavaScript function whenever a tab is expanded or collapsed. You can use a global variable to store the count and increment it each time the function is triggered. For example:
var tabACount = 0; // Global variable to store the count for Tab A
function onTabStateChange(executionContext) {
var formContext = executionContext.getFormContext();
var tab = formContext.ui.tabs.get("Tab_A"); // Get the tab by name
if (tab.getDisplayState() === "expanded") { // Check if the tab is expanded
tabACount++; // Increment the count
// alert("Tab A has been clicked " + tabACount + " times");
}
}
I have the "alert" command in there as a placeholder for you to store that variable someplace that you can use later for your analytics. Maybe create another field in the entity and store the value there.
To count the number of times an entity is clicked on, you can use the onRecordSelect event handler to execute a JavaScript function whenever an entity record is selected. Again, use a global variable to store the count and increment it each time the function is triggered. For example:
var accountCount = 0; // Global variable to store the count for Account entity
function onRecordSelect(executionContext) {
var formContext = executionContext.getFormContext();
var entityName = formContext.data.entity.getEntityName(); // Get the entity name
if (entityName === "account") { // Check if the entity is Account
accountCount++; // Increment the count
// alert("Account has been clicked " + accountCount + " times");
}
}
Again, the alert command is there as a placeholder to store the variable somewhere.
To count the number of times a field is modified, you can use the onChange event handler to execute a JavaScript function whenever a field value changes. You can use a global variable to store the count and increment it each time the function is triggered. For example:
var nameCount = 0; // Global variable to store the count for Name field
function onChange(executionContext) {
var formContext = executionContext.getFormContext();
var nameField = formContext.getAttribute("name"); // Get the field by name
if (nameField.getIsDirty()) { // Check if the field value has changed
nameCount++; // Increment the count
// alert("Name has been modified " + nameCount + " times");
}
}
And once again using the alert as a placeholder for putting that variable somewhere.
Hope that helps!