web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / View counts of Record
Power Pages
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:
I have the same question (0)
  • oliver.rodrigues Profile Picture
    9,482 Most Valuable Professional on at

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
sannavajjala87 Profile Picture

sannavajjala87 42 Super User 2026 Season 1

#2
Valantis Profile Picture

Valantis 33

#3
11manish Profile Picture

11manish 20

Last 30 days Overall leaderboard