{Dynamics 365 (ADX) portal Tips & Tricks} Show the top record from an entity view based using query filters in Dynamics 365 portals (ADX portals)

This is one more of my recent articles on ADX portals and this blog I am going to write on how to select the topmost record from an entity view using query filters.

Can’t depict the exact business scenario here but probably an example will get you started on how to get started with the query filters.

So let’s take an example here – What if someone asks you to print the the details of an employee with the highest salary from a specific view?

Let’s assume there we are leveraging the Contact table in CRM for Employee.

And the view I select is “Active Contacts” view.

Schema name of the salary field in the contact table – “new_salary”

In CRM, I created an Entity List called “Contact List” with a view “Active Contacts”

image

 

In the Portal side, in the Copy field just paste the below code.

{% entitylist name:”Contact List” %}
{%entityview logical_name:”contact”, name:”Active Contacts” %}
{% assign records = entityview.records| order_by: ‘new_salary’, ‘desc’%}
{% assign records2 = records| take: 1 %}

{% for record in records2 %}
Employee Name: {{ record.fullname }},  Salary: {{ record[“new_salary”]}}
{% endfor %}
{% endentityview %}
{% endentitylist %}

 

The code is pretty simple. I load the entity view “Active Contacts” from the Entity List “Contact List” that I created in the previous step.

The important part is the code highlighted in yellow.

I just take the output of view and then order by salary descending (default order is ascending) and in the next line I just take the top record from there.

That’s all. I now just print out the Employee Name and the Salary of the employee. Not a real world example but probably helps you get the idea.

 

-Debajit Dutta

(Dynamics MVP)

For training/ consulting please email at info@xrmforyou.com

Visit our products page – http://www.xrmforyou.com/products.html

Advertisements

{Dynamics 365 portals (ADX Portals)} Create a HTML table dynamically from Entity List in Dynamics 365 portals (ADX portals)

After my recent posts on ADX portal, I came across a question on how to dynamically load an entity list in a web-page. For people knowing on how to use Liquid, basically the user was trying to render an entity list using the below syntax.

{% entitylist name:”Account List” }%

{% endentitylist %}

Unfortunately the entire entity list will not render like this. Rather if the entitylist loads successfully, it would execute anything within the entity list block.

So if I write something like below.

{% entitylist name:”Account List” %}

Entity list Loaded successfully

{% endentitylist %}

It would render “Entity List Loaded Successfully”

So is there no way. Off-course, where there is will, there is a way.

So I decided to try the below approach. Please note that code does not give the entire solution as you would need lot of styling to achieve the final goal but this can definitely get you started.

Step 1: Create a web-template

The first step is to create a web-template. Since I would creating the HTML table dynamically, I require a web-template.

Go to CRM –> Portals –> Web templates

Select New and then the new template screen would be presented. Below is the screenshot of my template.

image

I have named id “Custom Grid Template”. Don’t worry about the source. Here it is below for full reference.
{% entitylist name:”Account List” %}
{% entityview %}
{% for col in entityview.columns %}
{{col.name}}

{% endfor %}

{% for e in entityview.records %}

{% for c in entityview.columns %}
{% assign attr = e[c.logical_name] %}
{% assign attr_type = attr.attribute_type|downcase %}
{% if attr.is_entity_reference %}
{{attr.name}}
{% elseif attr_type == ‘picklist’ %}
{{ attr.label }}
{% else %}
{{ attr }}
{% endif %}

{% endfor %}

{% endfor %}
{% endentityview %}
{% endentitylist %}
The code covers most of the scenarios that you are going to need to render a HTML table from EntityView or EntityList. Let’s run through all the highlighted parts.

  • First an entitylist is loaded with the statement : {% entitylist name:”Account List” %}
  • Second I take the default entityview of the entitylist. You can load the view with a specific name as well. {% entityview %}
  • In third highlighted section, I write code to create the header.

{% for col in entityview.columns %}
{{col.name}}

{% endfor %}

 

  • Pretty simple isn’t it. In the next highlighted rows, I first traverse through the existing rows of the view and find the attribute for each column using

{% assign attr = e[c.logical_name] %}

  • The interesting part is checking for the attribute type 

{% if attr.is_entity_reference %}
{{attr.name}}
{% elseif attr_type == ‘picklist’ %}

Till this point, I was OK. However to be honest, I was completely stuck on how to identify EntityReference and picklist.

And finally this came my to rescue. https://docs.microsoft.com/en-us/dynamics365/customer-engagement/portals/render-entity-list-current-page

A bit nerdy but awesome it is.

Step 2: Load the web template dynamically in the webpage

Below is the code for the same.

{% include ‘Custom Grid Template’ %}

And once you are done, below is the HTML table rendered dynamically. Off-course it is raw, but with a bit of styling it can look great.

image

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For training/ consulting please email at info@xrmforyou.com

Visit our products page – http://www.xrmforyou.com/products.html

 

{Quick Tip – Dynamics 365 portals (ADX)}–Dynamically show/ hide entity forms in Dynamics 365 portals (ADX portals) depending on Business Logic using Liquid templates

As I have been working mostly on Dynamics 365 portals, here goes another D365 portal post.

So here is the requirement. The portal customer applies for loan and then views the status of the loan request through the portal. However for every customer, there is one contact who is kind of Power User and is hence able to view some additional details on the Loan Request Form which the regular portal customers are not able to see,

The additional details are like.

  • The internal user with whom the loan request is currently pending
  • Additional internal communications among the internal team regarding the loan request.

 

So here is the set-up.

  • Two Forms for loan request entity
    • General form visible to all the users
    • Admin form visible to only the power users which shows the additional details

In the portal there is loan request web-page, which depending on the logged in-user, renders the Admin form.

To determine whether the portal user is a Power User or not, there is a field on the contact entity – “Is Power User” which need to be set. Below is the screenshot for the same.

schema name for the field – new_ispoweruser

image

 

Creating a loan request entity and then showing it up for the demo would take lot of time and also can’t use the screens from the client system due to legal issues. So here I would basically show you with the account entity, how you can dynamically render a entity form based on condition using Liquid.

 

Step 1 : Create a Blank Web-Page and set it up in the Portal Navigation

Go to CRM –> Portals –> Web Pages –> New

 

image

As you can see, I have created a Web Page with template as Blank Page. Notice carefully that I have not set any entity form or entity list. This is because I am going to set those up dynamically depending on conditions.

Now login to the portals as admin contact and then include this web page in the Navigation.

image

 

image

 

Clicking on Loan Status gives an empty page because we are using the blank page template.

 

2. Setting up of Entity forms

 

Now to mock up the previous scenario, I have created two forms for account entity.

  • Loan Request Admin Form
  • Loan Request General

image

 

Create Two entity Forms in CRM based on these two forms.

image

image

 

3. Set up the forms Dynamically using Liquid.

Login to the portal using the admin contact and edit the Copy content of the Loan Status Page.

image

 

 

 

 

Enter the below Liquid Code in the editor.

 

image

 

Pasting the same code inline

{% if user %}

{% if user.new_ispoweruser == true %}

{% entityform name:”Loan Request Admin Form” %}

{% endif %}

{% endif %}

{% entityform name: “Loan request General Form” %}

The code is pretty simple. All it is doing is checking if the logged in portal contact is a power contact, then load the admin form. The general form is always loaded by default

 

Save it and now when you refresh the page, you would see the power user is able to see both the forms. Using the same construct, you render forms dynamically based on business conditions.

Hope this helps.

 

Debajit Dutta

(Dynamics MVP)

For training/ consulting please email at info@xrmforyou.com

Visit our products page – http://www.xrmforyou.com/products.html

{Dynamics 365 + ADX portals}–Redeeming invitations, modifying invitation email and disabling open registrations in Dynamics 365 portals (ADX portals)

It’s been sometime that I have written a blog. Has been a lot for the past 2 months, personally and professionally and finally I am delighted to pen this down.

Has been working on Dynamics 365 portals lately a lot and thought of sharing some of my experience in user registration and redeeming invitations.

Here is my Dynamics Customer who has set-up D365 portals and want that users should not able to register by themselves.  Just for a bit of explanation, when you first time set-up D365 portals, the portals would allow a someone to register using custom identities through the Register Tab. Check for the below screenshot.

 

image

As you can see, all a user needs to do is enter an email address, set-up a user name and password and then register. Internally that would create a contact in CRM. Please note that the portal contact at this point of time would not have any roles associated to it and hence they won’t be able to see any authenticated content. However, there is a potential problem that your CRM contacts would be flooded with unwanted registrations.

So we needed to disable that. But how?

The feature is actually called ‘Open Registration’ in D365 portals.

Disable Open Registration in D365 portals

Go to Portals –> Site Settings in CRM

Search for Setting –> Authentication/Registration/OpenRegistrationEnabled and open the record.

Set the value of the setting to false and Save it back.

image

Now if you clear your cache and open your website in the portals, you would find the option to Register is missing.

image

 

Great! We have disabled user self registrations. Now what our customer wanted was to register portal users only through the invitation code. So basically the process is, the CRM administration would send invitation to the contact from the Contact. The contact would receive the invitation email in his/her email and then click on the email to register themselves with the portal.

So let’s see how it should be done. From the above point it is apparent that the email being sent out to the contact is one of the major component in this redeeming process. So let’s go ahead and first check what’s in the email.

Configuring the email to send Invitation:

Go to CRM-> Settings-> Processes

Search for the process – “Send Invitation”

Open the workflow and de-activate it. It should look like below.

 

image

Click on the ‘Set Properties’ in the highlighted step in the above email.

Once the email editor opens, just check for the email body. Below is the highlighted email body.

image

You can actually modify the email as per you needs. However the most important area of the email is setting the value of the URL highlighted above. This should be the same url the user is redirected when he/ she clicks on the ‘Redeem Invitation’ tab.

image

The url would be in the format – https://<your portal name>/register.

Just copy this URL and paste it in the email body.

image

Save & Close and activate the workflow.

 

Now we are at the final step

Sending Invitation to the contact:

Go to the contacts section in CRM and select the contact for which you want to send the invitation and then Click on the ‘Create Invitation’ on the ribbon menu.

image

 

You can set the expiry date of the invitation, the associated account for the portal contact on successful redeem.

image

 

Save it. Once saved, an invitation code would be automatically generated.

image

there is one more thing that you can do once a contact successfully register themselves using the invitation code.

You can set the We-roles for the user. I selected ‘Authenticated User’ web-role

image

 

Great! So now the invitation should be sent.

Click on Run Workflow from the ribbon and then select the ‘Send Invitation’ workflow we modified.

image

Once run, the user would get an email with the registration link. Below is the sample user registration link that the portal contact would receive in email.

https://xrmportal2.microsoftcrmportals.com/Register/?returnurl=%2f&invitation=EP2f2DlBSXdyww0ZUlcf92NC15YZJFeU-f3B6GNRWTLVOGA1rZ4h1SGxh8PJJOGiA5H7l1GFwXhcbnBCJCI3DNd-96cmQ3NQagxJLcFsd5XvNVCN3K3e5O38n9kS6vW5nVXJyg6wfwhEjCvebslf9II3vJq57gvNBuH2G0QTE-I-

 

Clicking on the above link, the portal user would redirected to the redeem page.

As you can see from the below screenshot, the invitation code is automatically inserted in the box.

image

 

Clicking on register will take to the next screen where the portal user can choose a login username and password of their choice. However

image

All set and done and the portal contact is now able to login to the D365 portal.

If we go back to CRM now, you would see the contact is now having an associated Web Role – ‘Authenticated Users’

image

 

P.S – > If you do not see the Redeem Invitation tab in your portal, there is some issue in Site settings. Please make sure the below site setting is enabled as true.

image

For developers/ customizers graduating from ADX 7.0 to D365 portals, in ADX 7.0  the Redeem Invitation tab was enabled using the site setting –> Authentication/Registration/RequiresInvitation

However this setting didn’t work for me in Dynamics Portals and it seems to have been replaced with the Site Setting –> Authentication/Registration/InvitationEnabled

Hope this helps!

 

Debajit Dutta

(Dynamics MVP)

For training/ consulting please email at info@xrmforyou.com

Visit our products page – http://www.xrmforyou.com/products.html

{Dynamics 365 + ADX portals} Using site setting to disable external authentication in Dynamics 365 portals.

In my previous blog posts, I have explained on how to enable custom authentication for your Dynamics 365 portals (ADX portals) with Identity providers like Azure Active Directory & Google/ facebook.

Link for  those:

Azure Active Directory – https://debajmecrm.com/2017/06/12/dynamics-365-portal-authentication-with-external-identities-part-i-authentication-with-azure-active-directory/

Google – https://debajmecrm.com/2017/06/13/dynamics-365-portal-authentication-with-external-identities-part-ii-authentication-with-google-account/

Below are the options my user get when they try to sign in or register in my portal.

image

So what in case you get a requirement to disable all these external authentication modes. Thinking that you might need to delete all the configurations. You worked so hard in setting this all up and you now need to delete them all. What if you need to re-enable again?

Well there is a life savior for you when it comes to D365 Portals. And believe me, it’s just creating a new site setting or changing the value if the site setting already exists.

Go to CRM –> Portals –> Site Settings.

image

 

In the list of Site Settings already present, search for the one with the Name = Authentication/Registration/ExternalLoginEnabled

If found open the existing record or create if not found.

Change the value of this record to false. Your setting should have the values in the below screenshot.

image

 

Save & Close the record.

Now go to your portal and refresh. You would see that the custom authentication options are no longer visible.

 

image

So in case you need to turn this back on, all you need to do is to go to your Site Settings and turn this flag back to true.

 

Simple isn’t it and I hope liked it.

-Debajit Dutta (Dynamics MVP)

For consulting & training, please drop a note to info@xrmforyou.com

(Visit our products page – http://www.xrmforyou.com/products-1.html to know more about our offerings)

(Dynamics 365 + ADX) Portal Authentication with External Identities Part-II – Authentication with Google Account

In my previous blog, I have explained on how to authenticate your Dynamics 365 portals with Azure Active Directory. You can read it here – https://debajmecrm.com/2017/06/12/dynamics-365-portal-authentication-with-external-identities-part-i-authentication-with-azure-active-directory/

However these days it’s common to come across websites which have options to sign-in with Google and Facebook.

Why are lovely portals be behind in this. And in case you are unaware, D365 portals has the support to configure this kind of authentication with Google and Facebook in a very simple way. So let’s explore on how to do this.

 

Step 1: Register your portal with Google API’s

 

Go to Google API Console – https://console.developers.google.com/projectselector/apis/library

Click on Credentials

image

 

In Create Credentials dropdown, Click on OAuth Client.

image

 

In the screen that comes up, Enter the below details

image

 

Name – This can be anything you want. I have named it as Microsoft portal identifier.

Authorized Javascript origins –  This is basically your D365 portal URL from where the request would originate.

Authorised redirect URIs – This is basically the call back URL once the validation is successful. As you can see I have entered https://xrmtr1.microsoftcrmportals.com/oauth2callback

Click on Save.

Once saved, you could see your client_id and client_secret. We do not need the client secret here. Just keep a note of the client id.

image

 

Step 2: Modify the Site Settings in Dynamics CRM

 

Go to CRM-> Portals-> Site Settings.

We need to create three site settings records here.

The first record would be identify the Authority URI from where we need to get the token.

image

I have put the  name as – Authentication/OpenIdConnect/Google Sign In/Authority. The part in bold is basically the name of the button as you want to show up in the login screen.

 

Second record of Site settings is to capture the value of the Client ID registered with the Google API’s

image

 

The third record is to capture the value of the redirect URI. This is the same value that you should put while registering D365 portal in Google API in Step 1.

image

 

And you are done.

Now when you try to register in your CRM portal, you could see the magical ‘Google Sign In’ button. Whooo. it was so complex Smile

image

Any body with a Google account can now register with your portal.

image

image

 

You would be asked for consent as per OAuth 2.0 protocol.

image

 

Once you provide your email and click on ‘Register’ you are done.

image

 

So simple and yet so powerful extensibility for your portals.

 

Hope you liked this post.

 

-Debajit Dutta (Dynamics MVP)

For Training and consulting please visit www.xrmforyou.com

(Visit our products page – http://www.xrmforyou.com/products-1.html to know more about our offerings)

Dynamics 365 (ADX) Portal Authentication with External Identities Part-I – Authentication with Azure Active Directory

Lately I have been working a lot on Dynamics 365 portals a lot and also delivering some trainings on the same. Don’t get much of a chance to work on Dynamics 365 portals (previously ADX portals), but when I get an opportunity, I make sure I don’t miss it.

And as I have been conducting training on CRM portals, I come across a lot of questions on Authentication of Dynamics 365 portals with external identities like Azure Active Directory/ Google/ Facebook. In the interest of my blog reader I have decided to pen down in detail on how to configure for such scenarios.

This blog will be a two part series. In this blog I will show you from scratch on how to set up Authentication of your Dynamics 365 portals with Azure Active Directory. In the next part I will show from scratch on how to set up the same with Google account.

First things first.

Launch a trial of Customer Portal for your Dynamics CRM. It’s pretty easy and I assume you know this. If not there are plenty of awesome articles which show on how to do the same. One such being – http://dynamicscrmcoe.com/install-dynamics-365-portals/

Ok. So we have our CRM portal set-up.

The following are my details:

Portal URL – https://xrmtr1.microsoftcrmportals.com

CRM URL – https://xrmtr50.crm8.dynamics.com

 

The first time when you launch the portal and try to sign in, you would be presented with a screen like below.

image

Because we are going to register the user with Azure AD, so click on the Register Tab.

image

Ok. So we already have a button called ‘Azure AD’ for registering the user. However as I told you, we will do it from scratch. So we will place our own custom button which when clicked will authenticate with our azure Active Directory. And in case you might be wondering, the Azure active directory will be a different domain than our Dynamics CRM domain (xrmtr50.onmicrosoft.com) for which the portal is configured.

So lets go with the set-up.

Step – 1 : Register your Dynamics 365 Portal application with Azure Active directory.

Login to your Azure subscription using https://portal.azure.com and search for Azure Active Directory

image

 

Click on App Registrations and then ‘New Application Registration’

image

image

 

Enter the details as required.

image

Name of the application – “Customer Portal Identifier”. This can be your any name you desire.

Application Type – Select Web app/ API

Sign-on URL – Enter the url of your D365 portal. In my case it is https://xrmtr1.microsoftcrmportals.com

Click on the Create Button.

image

 

Once done, you should see your App being listed here.

Click on the Application. You could see the Application ID. Note it down. We are going to use it later.

image

 

Click on Endpoints.

image

 

Take your federation metadata URL.

image

 

The federation metadata URL would look like below.

https://login.windows.net/95564beb-4dc8-43c2-bdda-12cea2056346/federationmetadata/2007-06/federationmetadata.xml

Remove the federation metadata URL and note the remaining URL. It would be in this format. https://login.windows.net/95564beb-4dc8-43c2-bdda-12cea2056346

Note it down. We are going to use it in the Next step.

 

Step 2: Setting up the Site Settings to Authenticate with our custom Azure AD.

 

Open your CRM and go to Portal –> Site Settings.

image

 

Click on New to Create a New Site Setting.

image

 

Carefully observe the name field – Authentication/OpenIdConnect/Azure AD Custom/Authority. The highlighted part in bold is your custom provider name that you want to show up in the portal.

In the value field, we have put the URL we got from the previous step.

Save & Close this.

 

Click new to create a new Site Setting

image

Here we are putting the Client ID. Put the same Client ID that we got when we registered our CRM Portal with Azure AD.

 

Now click again for a last time to create a new Site Setting and enter the below information.

image

 

Here we are setting the Redirect URL. This is URL which will be called back once the authentication is successful. In this case it’s our D365 Portal.

Save & Close.

So we are all set.

 

Now come to the login screen again and voila! Your new button is right there.

image

 

Click on the button. And you would be redirected to the login screen.

Once you enter the credentials of a user who belongs to your Azure Active Directory, you are registered in the portal

image

 

You will be asked to accept.

image

 

Once done, you will be logged in.

Wonderful isn’t it.

 

In my next post I would be walking in depth to configure your D365 portals with Google account. Here is the link for the same.

https://debajmecrm.com/2017/06/13/dynamics-365-portal-authentication-with-external-identities-part-ii-authentication-with-google-account/

Hope you like this.

 

-Debajit Dutta

(Dynamics MVP)

(Visit our products page – http://www.xrmforyou.com/products-1.html to know more about our offerings)

{Dynamics 365/ CRM} Access your cell values easily during on-change event of field in Dynamics CRM editable sub-grid.

It’s been some time that I wrote a blog. Been busy with the deliverable and tied up in loads of personal stuffs. However finally took out the time to pen down this small post which you might find useful.

So here I was in business as usual, writing some scripts on change of cell values in editable sub-grid. Just to mock up the requirement, the client had the following schema.

  • Parent entity
  • Child Entity. (bearing N:1 relationship with the Parent Entity)
  • There is an editable sub-grid of Child entity on the form of the Parent Entity
  • The Child Entity has three fields being shown on the editable grid
    • Name
    • Field 1
    • Field 2
  • On Change of Name in any of the rows of the sub-grid, the Field 1 should be set required as well as some default values should be shown in the field

You might be thinking, won’t a business rule do this. Yes certainly. And if your requirement is just as simple, then always go ahead with business rules. However for my client, the field values were based on some business logic and required to be set using complex operators which is unfortunately not possible using business rules.

And if you are stuck in the same situation, please read on.

Pretty simple isn’t it. So let’s first register on-change of the ‘Name’ field of the sub-grid. You might already be knowing this on how to do it, but there may be a small twist in the tale. So keep reading Smile

  • Open the form of the Parent Entity.
  • Highlight the sub-grid of the Child Entity on the Parent Entity and Click on Change Properties
  • In the pop-up dialog, go the Events Tab.

image

  • In the form properties, upload the webresource containing the script for the on-change of the name field.
  • In the Event Handlers section, select Field = “Name”

image

Click on Add, and then select the appropriate library. Put the function name which should be called on the on-change.

image

 

Before you close it out just like another mundane operation, please make sure “Pass Execution context as first parameter” is checked. We are going to need it a lot.

Save & Publish the form changes.

Now coming to the code. I have been surprised that there is very less of examples to show how to access field values on-change of cell values in editable sub-grid. So decided to pen this down.

Now coming to the function. Lets first see what is written. Off-course, your function is going to look lot more complex. However the basic framework to access the attributes and get/ set field values and other stuffs still remains the same.

function NameChange(eContext)
{
debugger;
// get the attribute which fired the onchange.
var nameAttr = eContext.getEventSource();

    // get the container for the attribute.
var attrParent = nameAttr.getParent();

    // get the value of the name.
var name = nameAttr.getValue();

    // var field1 Attribute
var field1 = attrParent.attributes.get(“new_field1”);

    field1.setValue(“<default value for field 1>”);

    // set field as mandatory.
field1.setRequiredLevel(“required”);
}

 

Ok. so let’s analyze bit by bit.

The first is to get the attribute which changed. the below line does exactly the same. And this is the reason why you need to check

var nameAttr = eContext.getEventSource();

The next is to get the gridRow object which contains the Name Attribute.

    var attrParent = nameAttr.getParent();

Although not used much, the getParent() is documented by Microsoft the Xrm.Page.ui.client control reference. Although I need to make sure whether calling it on attribute is supported or not. I will update on this blog only after my findings.

 

The remaining of the code is self explanatory. And you can see in this way, how easily you can access the attributes of the row which has been affected. And below is how it looks after I change the Name field in my sub-grid control.

image

Simple isn’t it.

Surprisingly there are very less examples on this. The other way if not this would be iterate through the selectedRows of the grid each time and then do a switch-case on each attribute of the row to achieve the desired result.

Hope it helps

-Debajit Dutta

(Dynamics MVP)

(Visit our products page – http://www.xrmforyou.com/products-1.html to know more about our offerings)

{Dynamics CRM + Outlook} Object does not support method or property “setSrc” in web resource control–Dynamics CRM outlook client

Recently my customer integrated their Dynamics CRM with outlook client. Everything was going fine until they reported that reported that when the CRM fields for Email entity are loading in Outlook client, they are getting the below error.

image

 

Ok. So first things first. Where and why is setSrc method is being used?

Well, my customer had a web resource on the email form and they were dynamically setting the URL of the webresource using the below code.

function FormLoad(){

var webResource = Xrm.Page.getControl(“<WebResourceName>”);

if(webResource != null){
webResource.setSrc(Xrm.Page.context.getClientUrl() + “<path to webresource>”);
}

}

 

The code seemed to work perfectly fine in Web Client. However in Outlook client it started throwing the above error.

So instead of setting the source of the Web Resource control, we decided to use the getObject method of the WebResource control. The getObject method returns the HTML IFrame element representing the webresource control.

And as many of you might be thinking whether it is supported to use this or not, the good news is, it is a documented method. So you can use it. And to my surprise, many were not aware of the same and was not sure whether it is supported or not.

And the last step would be to set the source of the IFrame element using its src attribute. To make the code more generic, the below code would work across your web as well as outlook clients.

var webResource = Xrm.Page.getControl(“<WebResourceName>”);

if (webResource != null) {
try{
webResource.setSrc(Xrm.Page.context.getClientUrl() + “<path to web resource>”);

catch(error){
var iframeObject = webResource.getObject();
iframeObject.src = Xrm.Page.context.getClientUrl() + “<path to web resource>”;
}
}

 

 

 

Off course you can be more explicit in the catch for the specific errors but this is just a demo code and you can modify as per your needs.

 

Hope this helps.

Debajit Dutta

(Visit our products page – http://www.xrmforyou.com/products-1.html to know more about our offerings)

{Dynamics CRM Auto-Number} Autonumbering solution for Dynamics CRM. Configurable, flexible options to choose from and uniqueness guaranteed

I am pleased to announce the new Auto Number tool from the stable of XrmForYou.com.

Before I walk you through all the features and how you can use the tool to your benefit, the eternal question, why again a new tool for an old requirement? Agreed it’s a requirement which every company implementing CRM must had at some point during their implementation lifecycle. And yes there a whole lot of solutions available which are targeted for that as well.

However, there are usually the following limitations I have faced while using many of the solutions

  • Not all generates unique numbers. Specially in case of data migration and during bulk uploads.
  • Many solutions uses Mutex lock. Even that does not guarantee uniqueness. And not an ideal solution for Online.
  • Many lack a good configuration page. Setting up an entity and field for an entity for auto number configuration is something you need to do manually many of the time
  • And last but not the least, how much a solution burns your pocket. You have impressive solutions in the market which covers all but perhaps you back down from implementing them because of budget constraints. We have tried to make this solution affordable as much as possible.

We have tried to cover up most of these scenarios and we hope you would find it useful for your business.

For trial and pricing, please write to info@xrmforyou.com

So let’s jump to the documentation.

The tool comes in the form of managed solution. Once you install the managed solution, open the configuration page.

image

Select an entity from the drop down. For my example, I selected Contact entity. Once you select the entity, all the ‘String’ and simple ‘Whole  Number’ fields would be populated for the selected entity.

image

For my example, I have created a String field ‘Auto Number Field’ which I will be using for the Auto Number.

I select the field.

I will explain the other options visible in this screen.

  • Disable configuration – By default, auto number configuration is enabled automatically once you select an entity and save your configurations in the tool. However you may choose to just disable the auto number for that entity without actually deleting your configurations that you took so much time to set-up.
  • Starting Number – By default it is set to 1. You can change it as required
  • Next Number – This field is for display purposes only and shows what number would be there in the next record that would be created. You can always reset the  ‘Next Number’ to the ‘Starting number’ by click on the ‘Reset Next Number’ button. 
  • Increment By – This field is used to determine by how much will the next number increment for the next record. You can set it to as desired. By default it is set to 1.

 

Prefix:

You have an option to choose a prefix value for you Auto Number. For that, just need check the checkbox ‘Insert Prefix’.

Once you check that you get the below options.

image

 

  • Prefix Value – Since I am using Contact entity, say for example I prefer my auto number value to be prefixed with C000. You can just put this value in the prefix.
  • Prefix Separator – Suppose I want that my auto number value and prefix value should be separated by a symbol. You can choose your desired list from the symbols provided in the dropdown. I have selected Hyphen(-) in my case.

P.S – If the field you have selected for Auto Number configuration is of type Whole Number, then prefix and suffix options will not be visible. Just for example – I have selected No. of Children which is of type Whole Number. Hence you could not see Insert Prefix & Insert Suffix Options.

image

 

Suffix:

The next option you have is to have a suffix appended to your auto number. For suffix, the tool provides you a whole lot of options. Let’s explore them

image

  • Suffix Generation Method – The first option you get is the Suffix Generation Method which can have two values
    • Auto Generated – If you select this option, you would see two additional fields showing up.
      • Suffix Length – The length of the suffix value
      • Suffix Type – You can choose between Whole Number & Alpha Numeric depending on the business requirement. Please note that you would have no control on the number generated. All the system would guarantee that it won’t be more than the length specified in the ‘Suffix Length’ field.

image

    • Manual – If you select this option, you would get the below option
      • Suffix Value– It’s a fixed value that you want to show for the suffix.

image

  • Suffix Separator – Same as explained for Prefix separator.

 

For my example  I have chosen Suffix Generation Method = “Auto Generated” & Suffix Separator = “At symbol(@)”

My final settings screenshot.


image

I click on Save to save my configurations.

Now let’s see, how an auto number is generated.

I create a new contact record and below is the auto number I get.

image

If you remember the I have selected alphanumeric for my suffix and put the suffix length – 5. that’s why the suffix is generated as a combination of numbers and characters of length 5.

 

This tool would give generated unique number for manual creation, bulk-imports or through data migration.

Last but not the least. The solutions comes with a security role – ‘Auto Number Reader’. Please make sure that all users using the the Auto Number are provided that role. Otherwise users other than system administrators would get the access error.

For trial and pricing, please write to info@xrmforyou.com

 

-Debajit Dutta

Try our tools

Sharepoint Metadata Manager and Attachment Extractor (http://www.xrmforyou.com/sharepoint-integrator-1.html)

Role Based Views in Dynamics CRM (http://www.xrmforyou.com/role-based-views.html)

Multiselect Picklist Control (http://www.xrmforyou.com/multi-select-picklist.html)

Record Cloner (http://www.xrmforyou.com/record-cloner.html)