Skip to main content

Notifications

Customer Service forum
Suggested answer

How can create a log (counter) page within CRM for every TAB that is clicked by a user (TAB tracking..)

Posted on by 5

I want to track how often certain TABS are clicked by users within CRM365. 

So let's say on the Account form there is a TAB called 'Adress' I want to know how often users click on that TAB.

It is not necessary to know which user has clicked how many times on that TAB but just how many times that TAB is clicked on by all users.

I was thinking on setting up an Entity called 'TAB logging'

And then have whole number fields like : 'Account_Adress' , 'Account_History' , 'Account_Information' , corresponding to the name of the TABS within t he account form.

Every time a TAB is openend / clicked on by a user then the number in e.g. field  'Account_Adress'  on entity 'TAB logging' is +1 higher.

I found a Jscript (carldesouza.com/run-javascript-when-user-clicks-on-unified-interface-tab/)  that responds to a user click on a TAB only now it shows an alert (that I don't want).

-----------------------------------------------------------------------------------

function OnLoad(executionContext) {
formContext = executionContext.getFormContext();

var PartnerDetailsTab = formContext.ui.tabs.get("Partner_Details");
PartnerDetailsTab.addTabStateChange(TabClicked);
}

function TabClicked() {
alert("Tab Clicked");
}

-------------------------------------------------------------------------------------

It would be great if somebody has a Jscript for this wish (or another solution).

The purpose of this TAB logging is to know how often a TAB is clicked on by users so that we can decide whether we want to invest more on certain data that is showed in that TAB or that we can remove the TAB because it is not used often enough.

Actually I think it's kind of weird that I cannot find anything on this kind of functionality.  

To be sure: I know there is Auditing in System Settings but that is not what I mean, also not the 'Start read auditing'  option which is way to intrusive. 

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How can create a log (counter) page within CRM for every TAB that is clicked by a user (TAB tracking..)

    Try something like this, I'm sure there is a slightly more efficient way to write this, but I had something kind of written up already that I just updated.  Let me know if you get stuck, most of the ALLCAPS stuff is where you need to replace with schema.

    function OnLoad(executionContext) {

    formContext = executionContext.getFormContext();

    var PartnerDetailsTab = formContext.ui.tabs.get("Partner_Details");

    PartnerDetailsTab.addTabStateChange(TabClicked);

    }

    function TabClicked(executionContext) {

    formContext = executionContext.getFormContext();

    var recordtoUpdatesGUID = DEPENDSHOWYOUAREPASSINGINTHEID;

    if(recordtoUpdatesGUID)

    {

    var guidOfNewTable = recordtoUpdatesGUID[0].id.slice(1, -1);

    Xrm.WebApi.retrieveRecord("SCHEMANAMEOFNEWTABLE", guidOfNewTable, "?$select=INTFIELDSCHEMANAME").then(

    function success(result){

    var currentCount = result.INTFIELDSCHEMANAME;

    var newCountFieldValue = currentCount + 1;

    var data =

    {

    "INTFIELDSCHEMANAME": newCountFieldValue

    }

    Xrm.WebApi.updateRecord("SCHEMANAMEOFNEWTABLE", guidOfNewTable, data).then(

    function success(result) {

    console.log("record updated");

    },

    function (error) {

    console.log(error.message);

    // handle error conditions

    }

    );

    },

    function (error) {

    //failed to find the record to update

    console.log(error.message);

    }

    );

    }

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,782 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,067 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,150

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans