Powerapps Portal/D365 portals: redirect the user to specific page if all/some mandatory contact information is not filled
Ask: Upon login to the power apps portal redirect the user to a specific page if all/some mandatory contact information is not filled.
Solution: Below is the code used to redirect from the home page to the contact page if the email of the contact record which is mandatory is not filled.
{% fetchxml query %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="contact">
<attribute name="fullname" />
<attribute name="telephone1" />
<attribute name="contactid" />
<order attribute="fullname" descending="false" />
<filter type="and">
<condition attribute="contactid" operator="eq" value="{{user.id}}"/>
<condition attribute="emailaddress1" operator="not-null" />
</filter>
</entity>
</fetch>
{% endfetchxml %}
var recordCount = "{{ query.results.entities.size }}";
if(recordCount == 0)
{
var contactId = "{{user.id}}";
if(contactId) //Validate whether the user is logged in or not
{
window.location.href = "/contactdetails/?id="+contactId;
}
}
Comments
Post a Comment