Saturday, 20 May 2017

Lock/Unlock User Account for Invalid Sign In Attempt - CRM Portal

This is very common requirement for any website/portal to lock and unlock user's account if they fails to login in 'N' numbers of attempt. This tutorial will walk you through the steps of configuring to lock users out if they fail to login too many times, and show you how to make them unlock back to access the Portal again.

How to Lock User's Account in CRM Portal:

Below are the few Portal Site Settings that define how and when an account becomes locked from authentication. When a certain number of failed password attempts are detected under a short period of time, the user account is locked for a period of time. The use can try again after the lockout period elapses.

Site Settings :

1. Authentication/UserManager/UserLockoutEnabledByDefault

Description : Indicates whether the user lockout is enabled when users are created. Default: true

2. Authentication/UserManager/DefaultAccountLockoutTimeSpan

Description : The default amount of time that a user is locked out for after Authentication/UserManager/MaxFailedAccessAttemptsBeforeLockout is reached. Default: 00:05:00 (5 mins).

3. Authentication/UserManager/MaxFailedAccessAttemptsBeforeLockout

Description : The maximum number of access attempts allowed before a user is locked out (if lockout is enabled). Default: 5. 

When the Lockout Enabled field on Contact is checked, it means that failed sign-in attempts will be counted in Access Failed Count to determine if a temporary user lockout should be activated. Once lockout is activated, the contact is unable to sign-in until the Lockout End Date has passed. If the Lockout Enabled field is unchecked, failed sign-in attempts are not recorded and the contact is allowed to fail any number of times without activating a lockout.
Fig: Portal User Authentication Information

How to Unlock User's Account in CRM Portal:

Once a user has been locked out due to too many failed login attempts, the account gets locked. At this point, the user can no longer use the reset password feature because when he clicks on it and types his username, it says the username is invalid. How come the reset password feature doesn't work when an account has been locked out?

So if your account get locked in CRM Portal, It's 'Lockout End Date' starts get appearing in above screenshots. Your won't be able to access your account until the Lockout End Date has passed.

But if you want to build up the functionality in Portal to make your account unlock before Lockout End Date has passed, You can make request to your Portal Administrator or anyone who have Admin rights on CRM. If someone will make this field blank or change the Lockout End Date to any past date, then User can start accessing his/her account.

If you do not want to perform this activity manually, you can create an 'On-Demand Workflow'in CRM, this workflow will just update Contact record by making the 'Lockout End Date' field blank..

You can make this functionality available on Portal also, Anyone who is having Portal Administrative privilege will login on portal. You can expose an 'Entity List' for Admin User only which will show list of all Contacts whose Account got locked by putting condition in Entity List View:

 'Contact whose 'Lockout End Date' contains data.

Administrator will select Contact and Run On Demand Workflow, this will trigger workflow in CRM and unlock the contact.






If you are not aware how to Run On Demand Workflow From Portal Entity List. Have a look Adxstudio Community this link.



Set or Auto populate value in Date Field - CRM Portal

I have been seen so many people asking a way to auto populate and set value in Portal Date field.Today In this article I am going to share a way to achieve the same.

Here is Adxstudio Community thread where lot of people were asking and facing challenge to set the value in Portal Date field :

https://community.adxstudio.com/forums/adxstudio-portals/76204747-a17d-e511-80dd-000d3a10150a


  1. $(document).ready(function(){
  2. var roundTripFormat = "YYYY-MM-DDTHH:mm:ss.0000000\\Z";
  3. var input = $("#AppointmentStartDate");
  4. var date = moment("06/28/2017").utc();
  5. input.val(date.format(roundTripFormat));
  6. input.siblings(".datetimepicker").data("datetimepicker").setValue(date);
  7. });


Also, if you want to perform some actions or operations on 'onchange'  event of Date field, you can achieve it through below syntax:

  1. $(document).ready(function(){
  2. var input = $("#AppointmentStartDate");
  3. input.siblings(".datetimepicker").data("datetimepicker").change(function(){ alert("Date has been changed."); });
  4. });

Custom Lookup Filtering in ADX/CRM Portal

As we all know that, Microsoft has given us the exciting new feature of being able to simply apply a custom filter to a lookup itself, meaning ALL views available in the lookup are filtered. In addition to this, we have also been given the ability to apply this filter immediately as the lookup is clicked, rather than on load or on change of the related fields.

OOB Lookup filtering is supported on Adxstudio and CRM Portal same like CRM.

But in few scenarios we cannot use CRM OOB Lookup Filter, we have to move towards Custom Lookup filter in CRM. But what about Portal where XRM Model is not supported yet ?

Custom Lookup Filtering is not supported on CRM Portal, but today in this article I am going to share a way through which we can achieve the Custom Lookup Filtering on Portal as well.

I would like to take a example here -

Requirement - 

Suppose I am exposing Account Entity Form on Portal, On this form I have a field 'Primary Contact', Requirement is to filter 'Primary Contact' based on Logged In User Account.

You would be thinking, if Portal supports CRM OOB Lookup Filtering then why we can't achieve it through OOB Lookup Filtering by keeping one Custom Account Lookup on Account form and filtered Primary Contact based on that.

Yes, you are right i was also thinking the same, but hold on "We cannot filtered record of any entity by keeping the lookup field of same entity" For example. We cannot Filtered Contacts based on Account by keeping one Account Lookup filed on Account entity itself.

Hope you understood this limitation in CRM, that's why we thought of to do the Custom Lookup Filter on Portal.

This is one requirement, you might come across other requirement also which require something similar like this.

So here is the way -


Step 1 : First of all Convert Lookup into Dropdown on which you want to apply Custom Lookup Filter. This you can make it possible through Entity Form Metadata.

You can have a look this link for more information > Convert CRM Lookup to Dropdown in CRM Portal.


Step 2 : Keep 'Parent Account' field on Account form (if you are not using it already for other purpose),
Note - If you have been using this field for other purpose, you can create custom Account lookup field also.


Step 3 : Intention for keeping this field on Account Form is to auto-populate logged In User's Account in this field.
For this Create one Entity Form Metadata on 'Account Entity Form' which will auto populate account's name of logged In User's in that field.

You can have a look this link for more information > How to auto populate data on Entity Form


Step 4 : So now we are done with all pre-requisites, Now the intent is to filter the dropdown and remove all the options from dropdown which we needs to filtered out or which we don't wants to be shown in dropdown list.

Here is the code to achieve the same -


$(document).ready(function () {

    //First we will get the Logged In User's Account (on the basis of that we have to filter 'Primary Contact'), which we have already stored on 'Parent Account' field using Entity Form Metadata. We kept this field only to get Logged In User's Account.
   
    // Get the Account Information (Guid) from that field
    var loggedInUserAccountGUID = $('#parentaccountid').val();

    // Get All accounts which does not belongs to logged in user's account
    var getContacts_FilteredOut = "/_odata/contacts/?$filter=parentcustomerid/Id%20ne%20(guid%27" + loggedInUserAccountGUID + "%27)";

    $.ajax({
        type: "GET",
        url: getContacts_FilteredOut,
        dataType: 'json'
    }).done(function (json) {

        // Got accounts collection which are not associated with logged In user's account
        var contactsColl = json.value;

        $.each(contactsColl, function (index, con)
        {
            // Remove these account from dropdown, so that only logged In user's account's contact will be rendered in dropdown
            if (con.contactid) {
                var contactGUID = con.contactid;

// We have removed the options instead of making it Hide, because IE browser does not support Hide/Show of dropdown options, We made it browser compatible.

                $("#primarycontactid option[value='" + contactGUID + "']").remove();
            }

        })
    })
});


Hope this article helps you, Please share your feedback and feel free to get in touch with my for any query.

Sunday, 7 May 2017

Edit Style/Layout of CRM Portal Login Page.

I have been seen lot of folks asking about how to make changes in OOB pages of CRM Portal like Sign In, Forget Password, Reset Password, Redeem Invitation Page etc.

Here are the few articles of Adxstudio Community where people are querying about the same :

https://facebook-community.adxstudio.com/forums/adxstudio-portals/05798180-d7fe-e311-80cd-00155dc0a3d4

https://community.adxstudio.com/forums/adxstudio-portals/05798180-d7fe-e311-80cd-00155dc0a3d4

https://community.adxstudio.com/forums/adxstudio-portals/eac043dc-8caf-e211-b55d-00155d423218

So today in this article I am going to discuss the steps to achieve the same without writing server side code.

As we all know that Microsoft has put significant investment into both improving the stability of the existing features and adding new capabilities and features like CRM Portal in Dynamics CRM 365.

You might have come across the requirement to make changes in OOB pages (as mentioned above) of CRM Portal without having access on server side code.

In Adxstudio On-Premise you had option of Portal server side code through which you could have play around with it, but in case of Adxstudio Online and CRM Portal you do not have access of server side code then in this case how you can edit or change Style/Layout of Portal OOB pages.

Here are the few steps through which you can change the style and layout of portal OOB pages without having access of server side code::

Step 1 - Copy the Sign In page Url of Portal and note it somewhere.

Step 2 - Login with Administrator account on Portal or login with user having administrator privileges

Step 3 - Now hit the Sign In page Url (which you have copied in Step 1) in another or same tab.

By doing this, Sign In page will get opened in Editable mode, Now you can make changes whatever you want.

Interesting thing is that, as soon as you make changes in Sign In page and Save it from outside, Portal creates a new record in 'Content Snippet' entity in CRM.

Step 4 - Open this record in CRM, and you can write your own and edit the existing HTML.

In the same way you can edit the style/layout of other pages of CRM Portal.














Hope this article will help someone. Please feel free to share your feedback,

Monday, 10 April 2017

Access Quick View Form values using JavaScript - CRM 2016

Quick view forms in Dynamics CRM 2016 allow you to display all the related entity information.

Is there a way to retrieve the field value on Quick View Form using JavaScript without additional
OData call to the associated entity?

The answer is Yes and here is the sample JavaScript to achieve the same:


function getQuickViewFormAttributeValues() {

    var quickViewControl = Xrm.Page.ui.quickForms.get("<QuickViewControlName>");

    if (quickViewControl != undefined)
    {
        if (quickViewControl.isLoaded())
        {
            // Access the value of the attribute bound to the constituent control
            var myattrValue1 = quickViewControl.getControl(0).getAttribute("<attribute name>").getValue();

            var myattrValue2 = quickViewControl.getControl(1).getAttribute("<attribute name>").getValue();

            console.log(myattrValue1 + myattrValue2);

            return;
        }
        else
        {
            // Wait for some time and check again
            setTimeout(getAttributeValue, 10);
        }
    }
    else
    {
        console.log("No data to display in the quick view control.");
        return;
    }    
}

CRM 2016 - How to Compare Two Dates Using JavaScript

I have encountered many confused developers attempting to compare two dates using JavaScript. There are many methods or algorithms for comparing dates but I am showing the simplest ways to compare dates as well as times using JavaScript.


This article will help you to resolve problems to compare two Dates using JavaScript :



<script type="text/javascript"language="javascript">

   function CompareDates() 
   {      
       var dateOne = new Date("2017/04/12"); //Year, Month, Date
       var dateTwo = new Date("2017/05/12"); //Year, Month, Date
       if (dateOne > dateTwo) 
        {
            alert("Date One is greater then Date Two.");
        }
        else
        {
            alert("Date Two is greater then Date One.");
        }
    } 
    CompareDate();
</script>

Sunday, 2 April 2017

LinkedIn Integration with Dynamics CRM Portals or Adxstudio Portals

LinkedIn plays a big role in the professional industry as this application really has a huge network, and lots of businesses uses this to build new relationships with customers, as well as prospect companies.  LinkedIn integration with CRM Portals or Adxstudio Portal lets you Sign In on Portals with LinkedIn Account as a External or Federated Account.

CRM Portals provide you the provisions of authentication mechanism using External Providers like :

  • Microsoft Account
  • Twitter
  • Facebook
  • Google
  • LinkedIn
  • Yammer
  • Yahoo

Today in this article, I am going to explain steps to configure CRM Portals to logged In with LinkedIn account.

Step 1: Create a new Dynamics CRM 365 trial instance (if you have not already made).

Step 2: Configure and Install CRM Portal as per your need (I have installed Customer Self-Service Portal). You can go through below link to configure Portal in Dynamics CRM 365.

http://arpitmscrmhunt.blogspot.in/2016/12/set-up-crm-portal-in-dynamics-crm-365.html

Step 3: Open LinkedIn Developer Network

Step 4 : Click 'Create Application' with below details :

  • Specify an Application Name, Description, etc.
  • Website URL: http://portal.contoso.com
  • OAuth User Agreement/Default Scope: r_basicprofie and r_emailaddress
  • OAuth 2.0 Redirect Urls: http://portal.contoso.com/signin-linkedin
  • Click Add Application
Step 5 : Once your are done by creating Application, You will be able to see below screen:




Step 6 : Now it's time to create some Site Settings in CRM:

You can get the below site settings from Adxstudio Community.

Site Setting NameDescription
Authentication/Registration/ExternalLoginEnabled
Enables or disables external account sign-in and registration. Default:true
Authentication/OpenAuth/[provider]/ClientId
Required. The client ID value from the provider application. It may also be referred to as an "App ID" or "Consumer Key".
The following setting names are allowed for backwards compatibility:
  • Authentication/OpenAuth/Twitter/ConsumerKey
  • Authentication/OpenAuth/Facebook/AppId
  • Authentication/OpenAuth/LinkedIn/ConsumerKey
Authentication/OpenAuth/[provider]/ClientSecret
Required. The client secret value from the provider application. It may also be referred to as an "App Secret" or "Consumer Secret".
The following setting names are allowed for backwards compatibility:
  • Authentication/OpenAuth/Twitter/ConsumerSecret
  • Authentication/OpenAuth/Facebook/AppSecret
  • Authentication/OpenAuth/LinkedIn/ConsumerSecret



Step 7: Once you done with these Site Settings configurations (under Portal > Site Settings) in CRM. You will be able to see LinkedIn Option on CRM Portal Sign In page.

























Step 8: As soon as you will click on LinkedIn, you will be redirected to LinkedIn Authenticated page for authentication



Step 9: Enter your credentials and click on 'Allow Access'. You will redirected now to Portal Profile page in order to complete your Registration.
Complete your registration by filling the given information and do click on 'Update', You will be redirected to Portal home page











Blogger Widgets