Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - Customize & Extend
Unanswered

View counts of Record

(0) ShareShare
ReportReport
Posted on by 56

Hi Everyone,

 

I have a field named view count and it should be updated numerically when ever a user open a record in the list view of a power pages page, when user opens a record first time of click of view details action button in the list view then the view count should update with 1 and if user opens same record for the 2nd time then the view count should update with 2 this is the scenario and it is working fine in the dynamics 365 on the on form load event of the form, you can find the dynamics 365 code below and I need it to work on the power pages portals page so can any one provide a solution to achieve this.

 

function updateViewCount() {
    var currentViewCount = Xrm.Page.getAttribute("new_viewcount").getValue();
    if (currentViewCount === null) {
        var newViewCount = 1;
    } else {
        var newViewCount = currentViewCount + 1;
    }
    Xrm.Page.getAttribute("new_viewcount").setValue(newViewCount);
    Xrm.Page.data.entity.save();
}
Xrm.Page.data.entity.addOnLoad(updateViewCount);

 

Thanks in advance..

Categories:
  • oliver.rodrigues Profile Picture
    9,315 Most Valuable Professional on at
    Re: View counts of Record

    If you want a single solution you would need to apply a plug-in on the Retrieve message, which is totally not recommended as it can lower the system performance.

     

    I would probably add a similar JS to the Portal that will perform that. Something like:

    $(document).ready(function(){
    
     let currentViewCount = $("#new_viewcount").val();
     $("#new_viewcount").val(currentViewCount + 1);
    });

     

     

     

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics