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 / If Authenticated go to...
Power Pages
Unanswered

If Authenticated go to home page, else go to Login page - how can I write this JS code - and where to use?

(0) ShareShare
ReportReport
Posted on by 520
Categories:
  • ragavanrajan Profile Picture
    7,044 Most Valuable Professional on at

    Hi @Robert94 

     

    You can mix liquid and JS together to achieve this. High-level idea 

     

    $(document).ready(function () {
     var roles = "{{ user.roles }}";
     console.log(roles);
     if(roles.contains("Administrators") > 0)
     alert("I am Admin");
    });
    

     

    The above script is using web role. Instead of alert, you can redirect to the specific page. 

     

    official example 

     

    {% if user %}
     
    Hello, {{ user.fullname | escape }}!
     
    {% else %}
     
    Hello, anonymous user!
     
    {% endif %}

     

    Official URL: Please click here 

     


    Hope it helps. 
    ------------

    If you like this post, give it a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.

     

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

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 18

#2
11manish Profile Picture

11manish 16 Super User 2026 Season 2

#3
anirudhev Profile Picture

anirudhev 4

Last 30 days Overall leaderboard