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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Portal: How can I redirect to login page if not logged in?

(0) ShareShare
ReportReport
Posted on by 15

We have a 'My Services' page on the portal and I would like the link to be there irrespective of the user being logged in or not. But if the user is not logged in and clicks on this link he/she should be re-directed to the login page. Is this possible? if yes, how?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at

    Hi Jasbir,

    I may not be aware of your actual requirement. But Ideally, if you do not want to give anonymous access to any of the portal page. you should use Web page Access Control Rules. By using this you can handle the hide/show of web links based on anonymous and authenticated users.

    Alternative option is,

    Use below code under Custom JavaScript section of 'My Services' webpage to achieve your functionality:

    {% if user %}

    {% else if %}

    window.open('https://'+window.location.host+'/SignIn?returnUrl='+window.location.pathname,'_self');

    {% endif %}

    For Example - I have used this for 'My Support' page.

    141666.Capture.PNG

     

    You can test it on my portal for 'My Support'  page :

    https://arpitdynamics.microsoftcrmportals.com/

     

    Please mark this answer verified to close this thread.

     

    Cheers

    Arpit

    https://arpitmscrmhunt.blogspot.in

     

  • Jasbir Dhaliwal Profile Picture
    15 on at

    Thanks, Arpit. That is exactly what I was looking for.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans